120 importer.
load(oc, nb);
132 delete myEdge.second;
136 delete myPlatformShape.second;
142 if (!oc.
isSet(
"osm-files")) {
145 const std::vector<std::string> files = oc.
getStringVector(
"osm-files");
146 std::vector<SUMOSAXReader*> readers;
169 for (
const std::string& file : files) {
178 if (!readers.back()->parseFirst(file) || !readers.back()->parseSection(
SUMO_TAG_NODE) ||
191 for (
const std::string& file : files) {
193 readers[idx]->setHandler(edgesHandler);
198 readers[idx] =
nullptr;
205 if (!oc.
getBool(
"osm.skip-duplicates-check")) {
209 std::set<const Edge*, CompareEdges> dupsFinder;
211 if (dupsFinder.count(it->second) > 0) {
216 dupsFinder.insert(it->second);
221 if (numRemoved > 0) {
230 std::map<long long int, int> nodeUsage;
232 for (
const auto& edgeIt :
myEdges) {
233 assert(edgeIt.second->myCurrentIsRoad);
234 for (
const long long int node : edgeIt.second->myCurrentNodes) {
240 if (nodesIt.second->tlsControlled || nodesIt.second->railwaySignal !=
SIGNAL_NONE || (nodesIt.second->pedestrianCrossing &&
myImportCrossings) ) {
243 nodeUsage[nodesIt.first]++;
252 for (
const auto& edgeIt :
myEdges) {
253 Edge*
const e = edgeIt.second;
267 NBNode* currentFrom = first;
269 std::vector<long long int> passed;
271 passed.push_back(*j);
274 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb, first, last);
275 currentFrom = currentTo;
277 passed.push_back(*j);
283 insertEdge(e, running, currentFrom, last, passed, nb, first, last);
286 WRITE_MESSAGEF(
TL(
"Skipped applying OSM placement on % edge(s): % due to non-explicit one-way and % due to opposite-direction auxiliary edges."),
302 for (
auto item : nodeUsage) {
308 size_t incomingEdgesNo = incomingEdges.size();
309 size_t outgoingEdgesNo = outgoingEdges.size();
311 for (
size_t i = 0; i < incomingEdgesNo; i++) {
319 auto const iEdge = incomingEdges[i];
323 std::string
const& iEdgeId = iEdge->getID();
324 std::size_t
const m = iEdgeId.find_first_of(
"#");
325 std::string
const& iWayId = iEdgeId.substr(0, m);
326 for (
size_t j = 0; j < outgoingEdgesNo; j++) {
327 auto const oEdge = outgoingEdges[j];
330 if (oEdge->getID().find(iWayId) != std::string::npos
332 && oEdge->getID().rfind(iWayId, 0) != 0) {
335 edgeVector.push_back(oEdge);
345 for (
size_t i = 0; i < outgoingEdgesNo; i++) {
347 auto const oEdge = outgoingEdges[i];
351 std::string
const& oEdgeId = oEdge->getID();
352 std::size_t
const m = oEdgeId.find_first_of(
"#");
353 std::string
const& iWayId = oEdgeId.substr(0, m);
354 for (
size_t j = 0; j < incomingEdgesNo; j++) {
355 auto const iEdge = incomingEdges[j];
356 if (iEdge->getID().find(iWayId) != std::string::npos
358 && iEdge->getID().rfind(iWayId, 0) != 0) {
361 edgeVector.push_back(iEdge);
375 const double layerElevation = oc.
getFloat(
"osm.layer-elevation");
376 if (layerElevation > 0) {
389 for (
const std::string& file : files) {
390 if (readers[idx] !=
nullptr) {
392 readers[idx]->setHandler(relationHandler);
402 std::set<std::string> stopNames;
404 stopNames.insert(item.second->getName());
411 WRITE_ERRORF(
"Unable to project coordinates for node '%'.", n->
id);
427 if (
node ==
nullptr) {
431 WRITE_ERRORF(
"Unable to project coordinates for junction '%'.",
id);
450 node->setParameter(
"virtual",
"true");
453 node->setParameter(
"moving-block",
"true");
462 if (!tlsc.
insert(tlDef)) {
469 node->setParameter(
"buffer_stop",
"true");
487 const std::vector<long long int>& passed,
NBNetBuilder& nb,
497 if (from ==
nullptr || to ==
nullptr) {
498 WRITE_ERRORF(
"Discarding edge '%' because the nodes could not be built.",
id);
507 assert(passed.size() >= 2);
508 if (passed.size() == 2) {
509 WRITE_WARNINGF(
TL(
"Discarding edge '%' which connects two identical nodes without geometry."),
id);
513 int intermediateIndex = (int) passed.size() / 2;
515 std::vector<long long int> part1(passed.begin(), passed.begin() + intermediateIndex + 1);
516 std::vector<long long int> part2(passed.begin() + intermediateIndex, passed.end());
517 index =
insertEdge(e, index, from, intermediate, part1, nb, first, last);
518 return insertEdge(e, index, intermediate, to, part2, nb, first, last);
520 const int newIndex = index + 1;
525 std::string routingType =
"";
533 std::vector<SumoXMLAttr> defaults;
536 extra = extra & ~SVC_BUS;
538 SVCPermissions permissions = (defaultPermissions & ~extraDis) | extra;
544 defaultsToOneWay =
true;
546 if (defaultPermissions ==
SVC_SHIP) {
548 permissions = defaultPermissions;
551 defaultsToOneWay =
false;
559 double distanceStart =
myOSMNodes[passed.front()]->positionMeters;
560 double distanceEnd =
myOSMNodes[passed.back()]->positionMeters;
561 const bool useDistance = distanceStart != std::numeric_limits<double>::max() && distanceEnd != std::numeric_limits<double>::max();
564 if (distanceStart < distanceEnd) {
584 std::vector<std::shared_ptr<NBPTStop> > ptStops;
585 for (
long long i : passed) {
589 std::shared_ptr<NBPTStop> existingPtStop = sc.
get(
toString(n->
id));
590 if (existingPtStop !=
nullptr) {
591 existingPtStop->registerAdditionalEdge(
toString(e->
id), id);
595 WRITE_ERRORF(
"Unable to project coordinates for node '%'.", n->
id);
599 sc.
insert(ptStops.back());
606 shape.push_back(pos);
626 WRITE_ERRORF(
"Unable to project coordinates for edge '%'.",
id);
632 if (streetName == e->
ref) {
650 const std::string& onewayBike = e->
myExtraTags[
"oneway:bicycle"];
651 if (onewayBike ==
"false" || onewayBike ==
"no" || onewayBike ==
"0") {
664 bool addForward =
true;
665 bool addBackward =
true;
681 if (addBackward && (onewayBike ==
"true" || onewayBike ==
"yes" || onewayBike ==
"1")) {
684 if (addForward && (onewayBike ==
"reverse" || onewayBike ==
"-1")) {
687 if (!addBackward && (onewayBike ==
"false" || onewayBike ==
"no" || onewayBike ==
"0")) {
701 if (addForward && !addBackward) {
703 }
else if (!addForward && addBackward) {
707 numLanesForward = dirFwd.
lanes;
708 numLanesBackward = dirBwd.
lanes;
709 }
else if (dirFwd.
lanes > 0) {
710 numLanesForward = dirFwd.
lanes;
712 }
else if (dirBwd.
lanes > 0) {
713 numLanesBackward = dirBwd.
lanes;
717 numLanesForward =
MAX2(1, (
int)std::ceil(effectiveLanes / 2.0));
718 numLanesBackward =
MAX2(1, effectiveLanes - numLanesForward);
724 numLanes = dir.
lanes;
732 resolveUnmarked(dirFwd,
WAY_FORWARD, hasForwardBusLanes, numLanesForward);
733 resolveUnmarked(dirBwd,
WAY_BACKWARD, hasBackwardBusLanes, numLanesBackward);
740 auto openContra = [&](
bool& addDir,
SVCPermissions& dirPerms,
int& numLanes,
743 || (isContraSide && motorContra != 0)
744 || (hasBus && dir.hasExplicitDirBus))) {
752 numLanes = dir.lanes > 0 ? dir.lanes : (hasBus ? dir.busLanes : 1);
755 openContra(addForward, forwardPermissions, numLanesForward, dirFwd,
WAY_FORWARD, hasForwardBusLanes, reverseOneway);
756 openContra(addBackward, backwardPermissions, numLanesBackward, dirBwd,
WAY_BACKWARD, hasBackwardBusLanes, !reverseOneway);
758 const int taggedLanes = (addForward ? numLanesForward : 0) + (addBackward ? numLanesBackward : 0);
762 forwardWidth = e->
myWidth / taggedLanes;
763 backwardWidth = forwardWidth;
777 if (speed <= 0 || speedBackward <= 0) {
781 if (e->
myNoLanes == 1 && addForward && addBackward) {
794 routingType =
"narrow";
800 if (!addForward && (cyclewayType &
WAY_FORWARD) != 0) {
803 forwardWidth = bikeLaneWidth;
808 if (!addBackward && (cyclewayType &
WAY_BACKWARD) != 0) {
811 backwardWidth = bikeLaneWidth;
812 numLanesBackward = 1;
826 if (!addForward && (sidewalkType &
WAY_FORWARD) != 0) {
833 }
else if (addSidewalk && addForward && (sidewalkType &
WAY_BOTH) == 0
834 && numLanesForward == 1 && numLanesBackward <= 1
841 if (!addBackward && (sidewalkType &
WAY_BACKWARD) != 0) {
845 numLanesBackward = 1;
848 }
else if (addSidewalk && addBackward && (sidewalkType &
WAY_BOTH) == 0
849 && numLanesBackward == 1 && numLanesForward <= 1
858 bool applyPlacement =
false;
859 double placementOffset = 0;
861 if (!explicitOneWay) {
865 }
else if (!(addForward && !addBackward)) {
869 }
else if (numLanesForward <= 0) {
871 WRITE_WARNINGF(
TL(
"Ignoring placement for edge '%' because lane count is invalid."),
id);
876 std::vector<double> laneWidths((
size_t)numLanesForward, defaultPlacementWidth);
879 for (
int i = 0; i < numLanesForward; ++i) {
886 WRITE_WARNINGF(
TL(
"Ignoring placement for edge '%' because lane index '%' is out of range [1, %]."),
891 double leftOffset = 0;
892 for (
int i = 0; i < laneIndex; ++i) {
893 leftOffset += laneWidths[(size_t)i];
895 double placementRefOffset = leftOffset;
897 placementRefOffset += laneWidths[(size_t)laneIndex];
899 placementRefOffset += laneWidths[(size_t)laneIndex] / 2.;
901 double totalWidth = 0;
902 for (
double laneWidth : laneWidths) {
903 totalWidth += laneWidth;
905 placementOffset = totalWidth / 2. - placementRefOffset;
906 applyPlacement =
true;
910 if (applyPlacement && fabs(placementOffset) > POSITION_EPS) {
915 WRITE_WARNINGF(
TL(
"Ignoring placement for edge '%' because offset shape computation failed."),
id);
917 applyPlacement =
false;
923 const int offsetFactor = lefthand ? -1 : 1;
937 if (applyPlacement) {
941 if (defaults.size() > 0) {
946 const std::string reverseID =
"-" + id;
953 assert(numLanesForward > 0);
957 if (markOSMDirection) {
995 if ((
int)nbe->
getLanes().size() != numForwardLanesFromWidthKey) {
996 WRITE_WARNINGF(
TL(
"Forward lanes count for edge '%' ('%') is not matching the number of lanes defined in width:lanes:forward key ('%'). Using default width values."),
997 id, nbe->
getLanes().size(), numForwardLanesFromWidthKey);
999 for (
int i = 0; i < numForwardLanesFromWidthKey; i++) {
1001 const int laneIndex = lefthand ? i : numForwardLanesFromWidthKey - i - 1;
1018 assert(numLanesBackward > 0);
1022 if (markOSMDirection) {
1054 if ((
int)nbe->
getLanes().size() != numBackwardLanesFromWidthKey) {
1055 WRITE_WARNINGF(
TL(
"Backward lanes count for edge '%' ('%') is not matching the number of lanes defined in width:lanes:backward key ('%'). Using default width values."),
1056 id, nbe->
getLanes().size(), numBackwardLanesFromWidthKey);
1058 for (
int i = 0; i < numBackwardLanesFromWidthKey; i++) {
1060 const int laneIndex = lefthand ? i : numBackwardLanesFromWidthKey - i - 1;
1111 std::map<NBNode*, std::vector<std::pair<double, double> > > layerForces;
1114 std::set<NBNode*> knownElevation;
1115 for (
auto& myEdge :
myEdges) {
1116 Edge* e = myEdge.second;
1120 if (
node !=
nullptr) {
1121 knownElevation.insert(
node);
1122 layerForces[
node].emplace_back(e->
myLayer * layerElevation, POSITION_EPS);
1127#ifdef DEBUG_LAYER_ELEVATION
1128 std::cout <<
"known elevations:\n";
1129 for (std::set<NBNode*>::iterator it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1130 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1131 std::cout <<
" node=" << (*it)->
getID() <<
" ele=";
1132 for (std::vector<std::pair<double, double> >::const_iterator it_ele = primaryLayers.begin(); it_ele != primaryLayers.end(); ++it_ele) {
1133 std::cout << it_ele->first <<
" ";
1141 std::map<NBNode*, double> knownEleMax;
1142 for (
auto it : knownElevation) {
1143 double eleMax = -std::numeric_limits<double>::max();
1144 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[it];
1145 for (
const auto& primaryLayer : primaryLayers) {
1146 eleMax =
MAX2(eleMax, primaryLayer.first);
1148 knownEleMax[it] = eleMax;
1151 bool changed =
true;
1154 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1157 / gradeThreshold * 3,
1159 for (
auto& neighbor : neighbors) {
1160 if (knownElevation.count(neighbor.first) != 0) {
1161 const double grade = fabs(knownEleMax[*it] - knownEleMax[neighbor.first])
1162 /
MAX2(POSITION_EPS, neighbor.second.first);
1163#ifdef DEBUG_LAYER_ELEVATION
1164 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";
1166 if (grade > gradeThreshold * 50 / 3.6 / neighbor.second.second) {
1168 const double eleMax =
MAX2(knownEleMax[*it], knownEleMax[neighbor.first]);
1169 if (knownEleMax[*it] < eleMax) {
1170 knownEleMax[*it] = eleMax;
1172 knownEleMax[neighbor.first] = eleMax;
1182 std::set<NBNode*> unknownElevation;
1183 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1184 const double eleMax = knownEleMax[*it];
1185 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1186 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1187 for (
auto& neighbor : neighbors) {
1188 if (knownElevation.count(neighbor.first) == 0) {
1189 unknownElevation.insert(neighbor.first);
1190 layerForces[neighbor.first].emplace_back(eleMax, neighbor.second.first);
1196 for (
auto it = unknownElevation.begin(); it != unknownElevation.end(); ++it) {
1197 double eleMax = -std::numeric_limits<double>::max();
1198 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1199 for (
const auto& primaryLayer : primaryLayers) {
1200 eleMax =
MAX2(eleMax, primaryLayer.first);
1202 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1203 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1204 for (
auto& neighbor : neighbors) {
1205 if (knownElevation.count(neighbor.first) == 0 && unknownElevation.count(neighbor.first) == 0) {
1206 layerForces[*it].emplace_back(0, neighbor.second.first);
1211#ifdef DEBUG_LAYER_ELEVATION
1212 std::cout <<
"summation of forces\n";
1214 std::map<NBNode*, double> nodeElevation;
1215 for (
auto& layerForce : layerForces) {
1216 const std::vector<std::pair<double, double> >& forces = layerForce.second;
1217 if (knownElevation.count(layerForce.first) != 0) {
1225#ifdef DEBUG_LAYER_ELEVATION
1226 std::cout <<
" node=" << it->first->getID() <<
" knownElevation=" << knownEleMax[it->first] <<
"\n";
1228 nodeElevation[layerForce.first] = knownEleMax[layerForce.first];
1229 }
else if (forces.size() == 1) {
1230 nodeElevation[layerForce.first] = forces.front().first;
1234 for (
const auto& force : forces) {
1235 distSum += force.second;
1237 double weightSum = 0;
1238 double elevation = 0;
1239#ifdef DEBUG_LAYER_ELEVATION
1240 std::cout <<
" node=" << it->first->getID() <<
" distSum=" << distSum <<
"\n";
1242 for (
const auto& force : forces) {
1243 const double weight = (distSum - force.second) / distSum;
1245 elevation += force.first *
weight;
1247#ifdef DEBUG_LAYER_ELEVATION
1248 std::cout <<
" force=" << it_force->first <<
" dist=" << it_force->second <<
" weight=" <<
weight <<
" ele=" << elevation <<
"\n";
1251 nodeElevation[layerForce.first] = elevation / weightSum;
1254#ifdef DEBUG_LAYER_ELEVATION
1255 std::cout <<
"final elevations:\n";
1256 for (std::map<NBNode*, double>::iterator it = nodeElevation.begin(); it != nodeElevation.end(); ++it) {
1257 std::cout <<
" node=" << (it->first)->getID() <<
" ele=" << it->second <<
"\n";
1261 for (
auto& it : nodeElevation) {
1267 for (
const auto& it : ec) {
1268 NBEdge* edge = it.second;
1270 const double length = geom.
length2D();
1271 const double zFrom = nodeElevation[edge->
getFromNode()];
1272 const double zTo = nodeElevation[edge->
getToNode()];
1277 for (
auto it_pos = geom.begin(); it_pos != geom.end(); ++it_pos) {
1278 if (it_pos != geom.begin()) {
1279 dist += (*it_pos).distanceTo2D(*(it_pos - 1));
1281 newGeom.push_back((*it_pos) +
Position(0, 0, zFrom + (zTo - zFrom) * dist / length));
1287std::map<NBNode*, std::pair<double, double> >
1289 std::map<NBNode*, std::pair<double, double> > result;
1290 std::set<NBNode*> visited;
1291 std::vector<NBNode*> open;
1292 open.push_back(
node);
1293 result[
node] = std::make_pair(0, 0);
1294 while (!open.empty()) {
1297 if (visited.count(n) != 0) {
1302 for (
auto e : edges) {
1305 s = e->getFromNode();
1309 const double dist = result[n].first + e->getGeometry().length2D();
1310 const double speed =
MAX2(e->getSpeed(), result[n].second);
1311 if (result.count(s) == 0) {
1312 result[s] = std::make_pair(dist, speed);
1314 result[s] = std::make_pair(
MIN2(dist, result[s].first),
MAX2(speed, result[s].second));
1316 if (dist < maxDist && knownElevation.count(s) == 0) {
1328 if (tc.
knows(type)) {
1339 std::vector<std::string> types;
1341 std::string t = tok.
next();
1343 if (std::find(types.begin(), types.end(), t) == types.end()) {
1346 }
else if (tok.
size() > 1) {
1348 WRITE_WARNINGF(
TL(
"Discarding unknown compound '%' in type '%' (first occurrence for edge '%')."), t, type,
id);
1352 if (types.empty()) {
1354 WRITE_WARNINGF(
TL(
"Discarding unusable type '%' (first occurrence for edge '%')."), type,
id);
1360 if (tc.
knows(newType)) {
1368 double maxSpeed = 0;
1373 bool defaultIsOneWay =
true;
1376 bool discard =
true;
1377 bool hadDiscard =
false;
1378 for (
auto& type2 : types) {
1395 if (hadDiscard && permissions == 0) {
1399 WRITE_WARNINGF(
TL(
"Discarding compound type '%' (first occurrence for edge '%')."), newType,
id);
1414 WRITE_MESSAGEF(
TL(
"Adding new type '%' (first occurrence for edge '%')."), type,
id);
1415 tc.
insertEdgeType(newType, numLanes, maxSpeed, prio, permissions, spreadType, width,
1416 defaultIsOneWay, sidewalkWidth, bikelaneWidth, 0, 0, 0);
1417 for (
auto& type3 : types) {
1432 std::vector<NIOSMNode*> nodes;
1433 std::vector<double> usablePositions;
1434 std::vector<int> usableIndex;
1438 if (
node->positionMeters != std::numeric_limits<double>::max()) {
1439 usablePositions.push_back(
node->positionMeters);
1440 usableIndex.push_back((
int)nodes.size());
1442 nodes.push_back(
node);
1444 if (usablePositions.size() == 0) {
1448 if (usablePositions.size() == 1) {
1449 WRITE_WARNINGF(
TL(
"Ambiguous railway kilometrage direction for way '%' (assuming forward)"),
id);
1451 forward = usablePositions.front() < usablePositions.back();
1454 for (
int i = 1; i < (int)usablePositions.size(); i++) {
1455 if ((usablePositions[i - 1] < usablePositions[i]) !=
forward) {
1456 WRITE_WARNINGF(
TL(
"Inconsistent railway kilometrage direction for way '%': % (skipping)"),
id,
toString(usablePositions));
1460 if (nodes.size() > usablePositions.size()) {
1469 double sign =
forward ? 1 : -1;
1471 for (
int i = usableIndex.front() - 1; i >= 0; i--) {
1472 nodes[i]->positionMeters = nodes[i + 1]->positionMeters - sign * shape[i].distanceTo2D(shape[i + 1]);
1475 for (
int i = usableIndex.front() + 1; i < (int)nodes.size(); i++) {
1476 if (nodes[i]->positionMeters == std::numeric_limits<double>::max()) {
1477 nodes[i]->positionMeters = nodes[i - 1]->positionMeters + sign * shape[i].distanceTo2D(shape[i - 1]);
1493 if (
node->position.size() > 0) {
1504 return std::numeric_limits<double>::max();
1510 if (type ==
"train") {
1512 }
else if (type ==
"subway") {
1514 }
else if (type ==
"aerialway") {
1516 }
else if (type ==
"light_rail" || type ==
"monorail") {
1518 }
else if (type ==
"share_taxi") {
1520 }
else if (type ==
"minibus") {
1522 }
else if (type ==
"trolleybus") {
1527 std::string stop =
"";
1530 }
else if (result ==
SVC_BUS) {
1545 bool multiLane = changeProhibition > 3;
1547 for (
int lane = 0; changeProhibition > 0 && lane < e->
getNumLanes(); lane++) {
1548 int code = changeProhibition % 4;
1553 changeProhibition = changeProhibition >> 2;
1570 for (
int lane = 0; lane <
MIN2(numLanes, dir.
busLanes); lane++) {
1575 for (
int lane = 0; lane < numLanes; lane++) {
1577 const int i = lefthand ? lane : numLanes - 1 - lane;
1582 if (i < (
int)designated.size() && designated[i]) {
1594 if (signs.empty()) {
1595 signs.insert(signs.begin(), signs2.begin(), signs2.end());
1597 for (
int i = 0; i < (int)
MIN2(signs.size(), signs2.size()); i++) {
1598 signs[i] |= signs2[i];
1610 for (
int i = 0; i < (int)turnSigns.size(); i++) {
1627 std::set<NIOSMNode*, CompareNodes>& uniqueNodes,
const OptionsCont& oc) :
1630 myCurrentNode(nullptr),
1632 myHierarchyLevel(0),
1633 myUniqueNodes(uniqueNodes),
1634 myImportElevation(oc.getBool(
"osm.elevation")),
1635 myDuplicateNodes(0),
1639 if (kv ==
"DEFAULT") {
1642 }
else if (kv ==
"ALL") {
1659 if (myHierarchyLevel != 2) {
1660 WRITE_ERROR(
"Node element on wrong XML hierarchy level (id='" + myLastNodeID +
1661 "', level='" +
toString(myHierarchyLevel) +
"').");
1665 if (action ==
"delete" || !ok) {
1671 myCurrentNode =
nullptr;
1672 const auto insertionIt = myToFill.lower_bound(
id);
1673 if (insertionIt == myToFill.end() || insertionIt->first !=
id) {
1675 const double tlon = attrs.
get<
double>(
SUMO_ATTR_LON, myLastNodeID.c_str(), ok);
1676 const double tlat = attrs.
get<
double>(
SUMO_ATTR_LAT, myLastNodeID.c_str(), ok);
1680 myCurrentNode =
new NIOSMNode(
id, tlon, tlat);
1685 delete myCurrentNode;
1686 myCurrentNode = *similarNode;
1689 myToFill.emplace_hint(insertionIt,
id, myCurrentNode);
1692 WRITE_ERROR(
TL(
"Attribute 'id' in the definition of a node is not of type long long int."));
1696 if (element ==
SUMO_TAG_TAG && myCurrentNode !=
nullptr) {
1697 if (myHierarchyLevel != 3) {
1698 WRITE_ERROR(
TL(
"Tag element on wrong XML hierarchy level."));
1702 const std::string& key = attrs.
get<std::string>(
SUMO_ATTR_K, myLastNodeID.c_str(), ok,
false);
1704 if (key ==
"highway" || key ==
"ele" || key ==
"crossing" || key ==
"railway" || key ==
"public_transport"
1705 || key ==
"name" || key ==
"train" || key ==
"bus" || key ==
"tram" || key ==
"light_rail" || key ==
"subway" || key ==
"station" || key ==
"noexit"
1706 || key ==
"crossing:barrier"
1707 || key ==
"crossing:light"
1708 || key ==
"railway:ref"
1712 const std::string& value = attrs.
get<std::string>(
SUMO_ATTR_V, myLastNodeID.c_str(), ok,
false);
1713 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
1714 myCurrentNode->tlsControlled =
true;
1715 }
else if (key ==
"crossing" && value.find(
"traffic_signals") != std::string::npos) {
1716 myCurrentNode->tlsControlled =
true;
1717 }
else if (key ==
"highway" && value.find(
"crossing") != std::string::npos) {
1718 myCurrentNode->pedestrianCrossing =
true;
1719 }
else if ((key ==
"noexit" && value ==
"yes")
1720 || (key ==
"railway" && value ==
"buffer_stop")) {
1721 myCurrentNode->railwayBufferStop =
true;
1722 }
else if (key ==
"railway" && value.find(
"crossing") != std::string::npos) {
1723 myCurrentNode->railwayCrossing =
true;
1724 }
else if (key ==
"crossing:barrier") {
1725 myCurrentNode->setParameter(
"crossing:barrier", value);
1726 }
else if (key ==
"crossing:light") {
1727 myCurrentNode->setParameter(
"crossing:light", value);
1728 }
else if (key ==
"railway:signal:direction") {
1729 if (value ==
"both") {
1730 myCurrentNode->myRailDirection =
WAY_BOTH;
1731 }
else if (value ==
"backward") {
1733 }
else if (value ==
"forward") {
1737 std::string kv = key +
"=" + value;
1738 std::string kglob = key +
"=";
1739 if (key ==
"railway:signal:train_protection" && value ==
"DE-ESO:ne14") {
1741 }
else if (myCurrentNode->railwaySignal ==
SIGNAL_NONE) {
1742 if ((std::find(myRailSignalRules.begin(), myRailSignalRules.end(), kv) != myRailSignalRules.end())
1743 || (std::find(myRailSignalRules.begin(), myRailSignalRules.end(), kglob) != myRailSignalRules.end())) {
1747 }
else if (
StringUtils::startsWith(key,
"railway:position") && value.size() > myCurrentNode->position.size()) {
1749 myCurrentNode->position = value;
1750 }
else if ((key ==
"public_transport" && value ==
"stop_position") ||
1751 (key ==
"highway" && value ==
"bus_stop")) {
1752 myCurrentNode->ptStopPosition =
true;
1753 if (myCurrentNode->ptStopLength == 0) {
1755 myCurrentNode->ptStopLength = myOptionsCont.getFloat(
"osm.stop-output.length");
1757 }
else if (key ==
"name") {
1758 myCurrentNode->name = value;
1759 }
else if (myImportElevation && key ==
"ele") {
1762 if (std::isnan(elevation)) {
1763 WRITE_WARNINGF(
TL(
"Value of key '%' is invalid ('%') in node '%'."), key, value, myLastNodeID);
1765 myCurrentNode->ele = elevation;
1768 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in node '%'."), key, value, myLastNodeID);
1770 }
else if (key ==
"station") {
1773 }
else if (key ==
"railway:ref") {
1774 myRailwayRef = value;
1781 const std::string info =
"node=" +
toString(myCurrentNode->id) +
", k=" + key;
1782 myCurrentNode->setParameter(key, attrs.
get<std::string>(
SUMO_ATTR_V, info.c_str(), ok,
false));
1791 if (myIsStation && myRailwayRef !=
"") {
1792 myCurrentNode->setParameter(
"railway:ref", myRailwayRef);
1794 myCurrentNode =
nullptr;
1795 myIsStation =
false;
1806 const std::map<long long int, NIOSMNode*>& osmNodes,
1807 std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes,
1812 myPlatformShapesMap(platformShapes),
1910 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
1912 if (action ==
"delete" || !ok) {
1913 myCurrentEdge =
nullptr;
1916 myCurrentEdge =
new Edge(
id);
1920 if (element ==
SUMO_TAG_ND && myCurrentEdge !=
nullptr) {
1930 ref =
node->second->id;
1931 if (myCurrentEdge->myCurrentNodes.empty() ||
1932 myCurrentEdge->myCurrentNodes.back() != ref) {
1933 myCurrentEdge->myCurrentNodes.push_back(ref);
1938 if (element ==
SUMO_TAG_TAG && myCurrentEdge !=
nullptr) {
1941 std::string buswaySpec;
1944 buswaySpec = key.substr(7);
1945 if (buswaySpec ==
"right" || buswaySpec ==
"left" || buswaySpec ==
"both") {
1952 const std::string info =
"way=" +
toString(myCurrentEdge->id) +
", k=" + key;
1953 myCurrentEdge->setParameter(key, attrs.
get<std::string>(
SUMO_ATTR_V, info.c_str(), ok,
false));
1958 && key !=
"maxspeed" && key !=
"maxspeed:type"
1959 && key !=
"zone:maxspeed"
1960 && key !=
"maxspeed:forward" && key !=
"maxspeed:backward"
1961 && key !=
"junction" && key !=
"name" && key !=
"tracks" && key !=
"layer"
1966 && key !=
"highspeed"
1970 && key !=
"postal_code"
1971 && key !=
"railway:preferred_direction"
1972 && key !=
"railway:bidirectional"
1973 && key !=
"railway:track_ref"
1976 && key !=
"emergency"
1978 && key !=
"electrified"
1979 && key !=
"segregated"
1985 && key !=
"placement"
1986 && key !=
"bus:lanes"
1987 && key !=
"bus:lanes:forward"
1988 && key !=
"bus:lanes:backward"
1989 && key !=
"psv:lanes"
1990 && key !=
"psv:lanes:forward"
1991 && key !=
"psv:lanes:backward"
1992 && key !=
"bicycle:lanes"
1993 && key !=
"bicycle:lanes:forward"
1994 && key !=
"bicycle:lanes:backward"
1997 && key !=
"public_transport") {
2000 const std::string value = attrs.
get<std::string>(
SUMO_ATTR_V,
toString(myCurrentEdge->id).c_str(), ok,
false);
2004 || key ==
"aeroway" || key ==
"aerialway" || key ==
"usage" || key ==
"service") {
2006 myCurrentEdge->myRoundaboutGuessExcluded =
true;
2009 if (key !=
"highway" || myTypeCont.knows(key +
"." + value)) {
2010 myCurrentEdge->myCurrentIsRoad =
true;
2013 if (key ==
"cycleway") {
2014 if (value ==
"no" || value ==
"none" || value ==
"separate") {
2015 myCurrentEdge->myCyclewayType =
WAY_NONE;
2016 }
else if (value ==
"both") {
2017 myCurrentEdge->myCyclewayType =
WAY_BOTH;
2018 }
else if (value ==
"right") {
2020 }
else if (value ==
"left") {
2022 }
else if (value ==
"opposite_track") {
2024 }
else if (value ==
"opposite_lane") {
2026 }
else if (value ==
"opposite") {
2031 if (key ==
"cycleway:left") {
2032 if (myCurrentEdge->myCyclewayType ==
WAY_UNKNOWN) {
2033 myCurrentEdge->myCyclewayType =
WAY_NONE;
2035 if (value ==
"yes" || value ==
"lane" || value ==
"track") {
2040 if (key ==
"cycleway:right") {
2041 if (myCurrentEdge->myCyclewayType ==
WAY_UNKNOWN) {
2042 myCurrentEdge->myCyclewayType =
WAY_NONE;
2044 if (value ==
"yes" || value ==
"lane" || value ==
"track") {
2045 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType |
WAY_FORWARD);
2049 if (key ==
"cycleway:both") {
2050 if (myCurrentEdge->myCyclewayType ==
WAY_UNKNOWN) {
2051 if (value ==
"no" || value ==
"none" || value ==
"separate") {
2052 myCurrentEdge->myCyclewayType =
WAY_NONE;
2054 if (value ==
"yes" || value ==
"lane" || value ==
"track") {
2055 myCurrentEdge->myCyclewayType =
WAY_BOTH;
2060 if (key ==
"cycleway" && value !=
"lane" && value !=
"track" && value !=
"opposite_track" && value !=
"opposite_lane") {
2069 if (key ==
"sidewalk") {
2070 if (value ==
"no" || value ==
"none" || value ==
"separate") {
2071 myCurrentEdge->mySidewalkType =
WAY_NONE;
2072 if (value ==
"separate") {
2075 }
else if (value ==
"both" || value ==
"yes") {
2076 myCurrentEdge->mySidewalkType =
WAY_BOTH;
2077 }
else if (value ==
"right") {
2079 }
else if (value ==
"left") {
2083 if (key ==
"sidewalk:left") {
2084 if (myCurrentEdge->mySidewalkType ==
WAY_UNKNOWN) {
2085 myCurrentEdge->mySidewalkType =
WAY_NONE;
2087 if (value ==
"yes") {
2090 if (value ==
"separate") {
2094 if (key ==
"sidewalk:right") {
2095 if (myCurrentEdge->mySidewalkType ==
WAY_UNKNOWN) {
2096 myCurrentEdge->mySidewalkType =
WAY_NONE;
2098 if (value ==
"yes") {
2099 myCurrentEdge->mySidewalkType = (
WayType)(myCurrentEdge->mySidewalkType |
WAY_FORWARD);
2101 if (value ==
"separate") {
2105 if (key ==
"sidewalk:both") {
2106 if (myCurrentEdge->mySidewalkType ==
WAY_UNKNOWN) {
2107 if (value ==
"no" || value ==
"none" || value ==
"separate") {
2108 myCurrentEdge->mySidewalkType =
WAY_NONE;
2109 if (value ==
"separate") {
2113 if (value ==
"yes") {
2114 myCurrentEdge->mySidewalkType =
WAY_BOTH;
2123 if (key ==
"busway") {
2124 if (value ==
"no" || value ==
"none") {
2127 if (value ==
"opposite_track" || value ==
"opposite_lane") {
2129 }
else if (buswaySpec ==
"right") {
2131 }
else if (buswaySpec ==
"left") {
2133 }
else if (buswaySpec ==
"both") {
2134 myCurrentEdge->myBuswayType = (
WayType)(myCurrentEdge->myBuswayType |
WAY_BOTH);
2139 std::string singleTypeID = key +
"." + value;
2140 if (key ==
"highspeed") {
2141 if (value ==
"no") {
2144 singleTypeID =
"railway.highspeed";
2146 addType(singleTypeID);
2148 }
else if (key ==
"bus" || key ==
"psv") {
2152 myCurrentEdge->myExtraAllowed |=
SVC_BUS;
2155 myCurrentEdge->myExtraDisallowed |=
SVC_BUS;
2158 myCurrentEdge->myExtraAllowed |=
SVC_BUS;
2161 }
else if (key ==
"emergency") {
2169 }
else if (key ==
"access") {
2170 if (value ==
"no") {
2176 std::vector<double> widthLanes;
2177 for (std::string width : values) {
2179 widthLanes.push_back(parsedWidth);
2182 if (key ==
"width:lanes") {
2183 myUnsuffixedWidthLanes = widthLanes;
2184 }
else if (key ==
"width:lanes:forward") {
2185 myCurrentEdge->myWidthLanesForward = widthLanes;
2186 }
else if (key ==
"width:lanes:backward") {
2187 myCurrentEdge->myWidthLanesBackward = widthLanes;
2189 WRITE_WARNINGF(
TL(
"Using default lane width for edge '%' as key '%' could not be parsed."),
toString(myCurrentEdge->id), key);
2192 WRITE_WARNINGF(
TL(
"Using default lane width for edge '%' as value '%' could not be parsed."),
toString(myCurrentEdge->id), value);
2194 }
else if (key ==
"width") {
2198 WRITE_WARNINGF(
TL(
"Using default width for edge '%' as value '%' could not be parsed."),
toString(myCurrentEdge->id), value);
2200 }
else if (key ==
"foot") {
2201 if (value ==
"use_sidepath" || value ==
"no") {
2203 }
else if (value ==
"yes" || value ==
"designated" || value ==
"permissive") {
2206 }
else if (key ==
"bicycle") {
2207 if (value ==
"use_sidepath" || value ==
"no") {
2209 }
else if (value ==
"yes" || value ==
"designated" || value ==
"permissive") {
2213 const std::string mode = key.substr(7);
2214 if (mode ==
"bicycle") {
2215 myCurrentEdge->myExtraTags[
"oneway:bicycle"] = value;
2217 if (value ==
"no" || value ==
"false" || value ==
"0") {
2218 static const std::pair<const char*, SVCPermissions> onewayModes[] = {
2228 for (
const auto& entry : onewayModes) {
2229 if (mode == entry.first) {
2230 myCurrentEdge->myOnewayContraPermissions |= entry.second;
2235 }
else if (key ==
"placement") {
2236 if (!interpretPlacement(value, myCurrentEdge->myPlacement, myCurrentEdge->myPlacementLane)) {
2237 WRITE_WARNINGF(
TL(
"Ignoring unsupported placement value '%' for edge '%'."), value, myCurrentEdge->id);
2239 }
else if (key ==
"lanes") {
2245 std::vector<std::string> list = st.
getVector();
2246 if (list.size() >= 2) {
2247 int minLanes = std::numeric_limits<int>::max();
2249 for (
auto& i : list) {
2251 minLanes =
MIN2(minLanes, numLanes);
2253 myCurrentEdge->myNoLanes = minLanes;
2256 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2260 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2262 }
else if (key ==
"lanes:forward" || key ==
"lanes:backward") {
2266 (key ==
"lanes:forward" ? myCurrentEdge->myDirForward : myCurrentEdge->myDirBackward).lanes = val;
2269 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2271 }
else if (key ==
"lanes:both_ways") {
2275 myCurrentEdge->myNoLanesBothWays = val;
2278 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2280 }
else if (key ==
"lanes:bus" || key ==
"lanes:psv") {
2281 const int cnt = parseBusLaneCount(key, value);
2283 myUnsuffixedBusLanesCount =
MAX2(myUnsuffixedBusLanesCount, cnt);
2286 }
else if (key ==
"lanes:bus:forward" || key ==
"lanes:psv:forward"
2287 || key ==
"lanes:bus:backward" || key ==
"lanes:psv:backward") {
2288 const int cnt = parseBusLaneCount(key, value);
2291 Edge::DirLaneInfo& dir = fwd ? myCurrentEdge->myDirForward : myCurrentEdge->myDirBackward;
2296 }
else if (key ==
"maxspeed:forward" && myMaxSpeedForward ==
MAXSPEED_UNGIVEN) {
2297 myMaxSpeedForward = interpretSpeed(key, value);
2299 myMaxSpeedExplicit = interpretSpeed(key, value);
2300 }
else if ((key ==
"maxspeed:type" || key ==
"zone:maxspeed") && myMaxSpeedFallbackValue.empty()) {
2301 myMaxSpeedFallbackKey = key;
2302 myMaxSpeedFallbackValue = value;
2303 }
else if (key ==
"maxspeed:backward" && myCurrentEdge->myMaxSpeedBackward ==
MAXSPEED_UNGIVEN) {
2304 myCurrentEdge->myMaxSpeedBackward = interpretSpeed(key, value);
2305 }
else if (key ==
"junction") {
2306 if ((value ==
"roundabout" || value ==
"circular") && myCurrentEdge->myIsOneWay.empty()) {
2307 myCurrentEdge->myIsOneWay =
"yes";
2309 if (value ==
"roundabout") {
2310 myCurrentEdge->myAmInRoundabout =
true;
2311 }
else if (value ==
"circular") {
2312 myCurrentEdge->myRoundaboutGuessExcluded =
true;
2313 myCurrentEdge->myIsCircularJunction =
true;
2315 }
else if (key ==
"oneway") {
2316 myCurrentEdge->myIsOneWay = value;
2317 }
else if (key ==
"name") {
2318 myCurrentEdge->streetName = value;
2319 }
else if (key ==
"ref") {
2320 myCurrentEdge->ref = value;
2321 myCurrentEdge->setParameter(
"ref", value);
2322 }
else if (key ==
"layer") {
2326 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2328 }
else if (key ==
"tracks") {
2331 myCurrentEdge->myIsOneWay =
"true";
2333 WRITE_WARNINGF(
TL(
"Ignoring track count % for edge '%'."), value, myCurrentEdge->id);
2336 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2338 }
else if (key ==
"railway:preferred_direction") {
2339 if (value ==
"both") {
2341 }
else if (value ==
"backward") {
2343 }
else if (value ==
"forward") {
2346 }
else if (key ==
"railway:bidirectional") {
2347 if (value ==
"regular") {
2348 myCurrentEdge->myRailDirection = (myCurrentEdge->myRailDirection |
WAY_BOTH) & ~
WAY_UNKNOWN;
2350 }
else if (key ==
"electrified" || key ==
"segregated") {
2351 if (value !=
"no") {
2352 myCurrentEdge->myExtraTags[key] = value;
2354 }
else if (key ==
"railway:track_ref") {
2355 myCurrentEdge->setParameter(key, value);
2356 }
else if (key ==
"public_transport" && value ==
"platform") {
2357 myCurrentEdge->myExtraTags[
"platform"] =
"yes";
2362 }
else if ((key ==
"parking:right" || key ==
"parking:lane:right") && !
StringUtils::startsWith(value,
"no")) {
2364 }
else if (key ==
"change" || key ==
"change:lanes") {
2365 myCurrentEdge->myChangeForward = myCurrentEdge->myChangeBackward = interpretChangeType(value);
2366 }
else if (key ==
"change:forward" || key ==
"change:lanes:forward") {
2367 myCurrentEdge->myChangeForward = interpretChangeType(value);
2368 }
else if (key ==
"change:backward" || key ==
"change:lanes:backward") {
2369 myCurrentEdge->myChangeBackward = interpretChangeType(value);
2370 }
else if (key ==
"vehicle:lanes") {
2371 myUnsuffixedLaneUse.push_back({value,
SVC_PASSENGER,
false});
2372 myUnsuffixedLaneUse.push_back({value,
SVC_PRIVATE,
false});
2373 }
else if (key ==
"vehicle:lanes:forward") {
2376 }
else if (key ==
"vehicle:lanes:backward") {
2379 }
else if (key ==
"bus:lanes") {
2380 myUnsuffixedLaneUse.push_back({value,
SVC_BUS,
true});
2381 }
else if (key ==
"bus:lanes:forward") {
2382 interpretLaneUse(value,
SVC_BUS,
true);
2383 myCurrentEdge->myDirForward.hasBusSpec =
true;
2384 }
else if (key ==
"bus:lanes:backward") {
2385 interpretLaneUse(value,
SVC_BUS,
false);
2386 myCurrentEdge->myDirBackward.hasBusSpec =
true;
2387 }
else if (key ==
"psv:lanes") {
2388 myUnsuffixedLaneUse.push_back({value,
SVC_BUS,
true});
2389 myUnsuffixedLaneUse.push_back({value,
SVC_TAXI,
true});
2390 }
else if (key ==
"psv:lanes:forward") {
2391 interpretLaneUse(value,
SVC_BUS,
true);
2392 interpretLaneUse(value,
SVC_TAXI,
true);
2393 myCurrentEdge->myDirForward.hasBusSpec =
true;
2394 }
else if (key ==
"psv:lanes:backward") {
2395 interpretLaneUse(value,
SVC_BUS,
false);
2396 interpretLaneUse(value,
SVC_TAXI,
false);
2397 myCurrentEdge->myDirBackward.hasBusSpec =
true;
2398 }
else if (key ==
"bicycle:lanes") {
2399 myUnsuffixedLaneUse.push_back({value,
SVC_BICYCLE,
false});
2400 }
else if (key ==
"bicycle:lanes:forward") {
2402 }
else if (key ==
"bicycle:lanes:backward") {
2416 std::vector<int> turnCodes;
2417 for (std::string codeList : values) {
2420 if (codes.size() == 0) {
2423 for (std::string code : codes) {
2424 if (code ==
"" || code ==
"none" || code ==
"through") {
2426 }
else if (code ==
"left" || code ==
"sharp_left") {
2428 }
else if (code ==
"right" || code ==
"sharp_right") {
2430 }
else if (code ==
"slight_left") {
2432 }
else if (code ==
"slight_right") {
2434 }
else if (code ==
"reverse") {
2436 }
else if (code ==
"merge_to_left" || code ==
"merge_to_right") {
2440 turnCodes.push_back(turnCode);
2460 if (!myCurrentEdge->myHighWayType.empty() && singleTypeID !=
"railway.highspeed") {
2461 if (myCurrentEdge->myHighWayType ==
"railway.highspeed") {
2466 std::vector<std::string> types =
StringTokenizer(myCurrentEdge->myHighWayType,
2468 types.push_back(singleTypeID);
2471 myCurrentEdge->myHighWayType = singleTypeID;
2478 if (mySpeedMap.find(value) != mySpeedMap.end()) {
2479 return mySpeedMap[value];
2482 if (value.size() > 3 && value[2] ==
':') {
2483 if (value.substr(3, 4) ==
"zone") {
2484 value = value.substr(7);
2485 if (!value.empty() && (value[0] ==
':' || value[0] ==
'_')) {
2486 value = value.substr(1);
2489 value = value.substr(3);
2495 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
2496 toString(myCurrentEdge->id) +
"'.");
2507 for (
const std::string& val : values) {
2510 }
else if (val ==
"not_left") {
2512 }
else if (val ==
"not_right") {
2515 result = result << 2;
2518 result = result >> 2;
2520 if (values.size() > 1) {
2533 if (tokens.size() != 2) {
2537 if (where ==
"left_of") {
2539 }
else if (where ==
"right_of") {
2541 }
else if (where ==
"middle_of") {
2553 if (laneIndex <= 0) {
2565 std::vector<bool>& designated =
forward ? myCurrentEdge->myDesignatedLaneForward : myCurrentEdge->myDesignatedLaneBackward;
2566 std::vector<SVCPermissions>& allowed =
forward ? myCurrentEdge->myAllowedLaneForward : myCurrentEdge->myAllowedLaneBackward;
2567 std::vector<SVCPermissions>& disallowed =
forward ? myCurrentEdge->myDisallowedLaneForward : myCurrentEdge->myDisallowedLaneBackward;
2568 designated.resize(
MAX2(designated.size(), values.size()),
false);
2572 for (
const std::string& val : values) {
2573 if (val ==
"yes" || val ==
"permissive") {
2575 }
else if (val ==
"lane" || val ==
"designated") {
2577 designated[i] =
true;
2578 }
else if (val ==
"no") {
2579 disallowed[i] |= svc;
2581 WRITE_WARNINGF(
TL(
"Unknown lane use specifier '%' ignored for way '%'"), val, myCurrentEdge->id);
2590 if (value ==
"yes") {
2593 if (value ==
"no" || value ==
"none") {
2598 return cnt > 0 ? cnt : 0;
2600 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
2608 myUnsuffixedWidthLanes.clear();
2609 myUnsuffixedTurnSigns.clear();
2610 myUnsuffixedLaneUse.clear();
2611 myUnsuffixedBusLanesCount = 0;
2612 myUnsuffixedBusLanesClasses = 0;
2615 myMaxSpeedFallbackKey.clear();
2616 myMaxSpeedFallbackValue.clear();
2622 const bool reverseOneway = (myCurrentEdge->myIsOneWay ==
"-1" || myCurrentEdge->myIsOneWay ==
"reverse");
2624 const bool defaultOneway = myCurrentEdge->myIsOneWay.empty()
2625 && myTypeCont.knows(myCurrentEdge->myHighWayType)
2626 && myTypeCont.getEdgeTypeIsOneWay(myCurrentEdge->myHighWayType);
2629 const int explicitBusFwd = dirFwd.
busLanes;
2630 const int explicitBusBwd = dirBwd.
busLanes;
2631 const int explicitBusSum = explicitBusFwd + explicitBusBwd;
2634 if (!myUnsuffixedWidthLanes.empty()) {
2635 std::vector<double>& target = reverseOneway ? myCurrentEdge->myWidthLanesBackward : myCurrentEdge->myWidthLanesForward;
2636 if (target.empty()) {
2637 target = std::move(myUnsuffixedWidthLanes);
2640 if (!myUnsuffixedTurnSigns.empty()) {
2641 mergeTurnSigns(reverseOneway ? myCurrentEdge->myTurnSignsBackward : myCurrentEdge->myTurnSignsForward, myUnsuffixedTurnSigns);
2643 for (
const auto& entry : myUnsuffixedLaneUse) {
2644 interpretLaneUse(entry.value, entry.svc, !reverseOneway);
2645 if (entry.isBusOrPsv) {
2646 (reverseOneway ? dirBwd : dirFwd).hasBusSpec =
true;
2649 if (myUnsuffixedBusLanesCount > 0) {
2652 dir.
busClasses |= myUnsuffixedBusLanesClasses;
2654 if (reverseOneway) {
2655 applyBus(dirBwd, myUnsuffixedBusLanesCount);
2656 }
else if (explicitOneway || defaultOneway) {
2657 applyBus(dirFwd, myUnsuffixedBusLanesCount);
2658 }
else if (myUnsuffixedBusLanesCount >= 2 && myUnsuffixedBusLanesCount % 2 == 0) {
2659 applyBus(dirFwd, myUnsuffixedBusLanesCount / 2);
2660 applyBus(dirBwd, myUnsuffixedBusLanesCount / 2);
2662 applyBus(dirFwd, myUnsuffixedBusLanesCount);
2667 if ((explicitOneway || defaultOneway || reverseOneway) && (myCurrentEdge->myOnewayContraPermissions &
SVC_BUS) != 0) {
2669 myCurrentEdge->myBuswayType = (
WayType)(myCurrentEdge->myBuswayType | contra);
2673 double baseSpeed = myMaxSpeedExplicit;
2675 baseSpeed = interpretSpeed(myMaxSpeedFallbackKey, myMaxSpeedFallbackValue);
2677 myCurrentEdge->myMaxSpeedBase = baseSpeed;
2678 myCurrentEdge->myMaxSpeed = (myMaxSpeedForward !=
MAXSPEED_UNGIVEN) ? myMaxSpeedForward : baseSpeed;
2682 const int dirSum = dirFwd.
lanes + dirBwd.
lanes + myCurrentEdge->myNoLanesBothWays;
2683 if (myCurrentEdge->myNoLanes < 0) {
2684 myCurrentEdge->myNoLanes = dirSum;
2685 }
else if (myCurrentEdge->myNoLanes != dirSum) {
2686 if (explicitBusSum > 0 && myCurrentEdge->myNoLanes == dirSum + explicitBusSum) {
2688 dirFwd.
lanes += explicitBusFwd;
2689 dirBwd.
lanes += explicitBusBwd;
2691 WRITE_WARNINGF(
TL(
"Lane count (%) does not match sum of directional lanes (%) for edge '%'."),
2692 myCurrentEdge->myNoLanes, dirSum, myCurrentEdge->id);
2693 if (myCurrentEdge->myNoLanes > dirSum) {
2694 myCurrentEdge->myNoLanes = dirSum;
2704 if (element ==
SUMO_TAG_WAY && myCurrentEdge !=
nullptr) {
2705 if (myCurrentEdge->myCurrentIsRoad) {
2707 const auto insertionIt = myEdgeMap.lower_bound(myCurrentEdge->id);
2708 if (insertionIt == myEdgeMap.end() || insertionIt->first != myCurrentEdge->id) {
2710 myEdgeMap.emplace_hint(insertionIt, myCurrentEdge->id, myCurrentEdge);
2712 delete myCurrentEdge;
2714 }
else if (myCurrentEdge->myExtraTags.count(
"platform") != 0) {
2715 const auto insertionIt = myPlatformShapesMap.lower_bound(myCurrentEdge->id);
2716 if (insertionIt == myPlatformShapesMap.end() || insertionIt->first != myCurrentEdge->id) {
2718 myPlatformShapesMap.emplace_hint(insertionIt, myCurrentEdge->id, myCurrentEdge);
2720 delete myCurrentEdge;
2723 delete myCurrentEdge;
2725 myCurrentEdge =
nullptr;
2734 const std::map<long long int, NIOSMNode*>& osmNodes,
2735 const std::map<long long int, Edge*>& osmEdges,
NBPTStopCont* nbptStopCont,
2736 const std::map<long long int, Edge*>& platformShapes,
2741 myOSMEdges(osmEdges),
2743 myNBPTStopCont(nbptStopCont),
2744 myNBPTLineCont(nbptLineCont),
2756 myIsRestriction =
false;
2763 myRestrictionType = RestrictionType::UNKNOWN;
2764 myPlatforms.clear();
2766 myPlatformStops.clear();
2768 myIsStopArea =
false;
2771 myRouteColor.setValid(
false);
2779 myCurrentRelation = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
2781 if (action ==
"delete" || !ok) {
2787 myNightService =
"";
2796 const long long int ref = attrs.
get<
long long int>(
SUMO_ATTR_REF,
nullptr, ok);
2797 if (role ==
"via") {
2800 if (memberType ==
"way" && checkEdgeRef(ref)) {
2802 }
else if (memberType ==
"node") {
2809 }
else if (role ==
"from" && checkEdgeRef(ref)) {
2811 }
else if (role ==
"to" && checkEdgeRef(ref)) {
2815 myStops.push_back(ref);
2819 if (memberType ==
"way") {
2820 const std::map<long long int, NIImporter_OpenStreetMap::Edge*>::const_iterator& wayIt =
myPlatformShapes.find(ref);
2823 platform.
isWay =
true;
2825 myPlatforms.push_back(platform);
2827 }
else if (memberType ==
"node") {
2829 myStops.push_back(ref);
2830 myPlatformStops.insert(ref);
2832 platform.
isWay =
false;
2834 myPlatforms.push_back(platform);
2837 }
else if (role ==
"station") {
2839 }
else if (role.empty()) {
2841 if (memberType ==
"way") {
2842 myWays.push_back(ref);
2843 }
else if (memberType ==
"node") {
2845 if (it !=
myOSMNodes.end() && it->second->hasParameter(
"railway:ref")) {
2848 myStops.push_back(ref);
2859 if (key ==
"type" || key ==
"restriction") {
2861 if (key ==
"type" && value ==
"restriction") {
2862 myIsRestriction =
true;
2865 if (key ==
"type" && value ==
"route") {
2869 if (key ==
"restriction") {
2872 if (value.substr(0, 5) ==
"only_") {
2873 myRestrictionType = RestrictionType::ONLY;
2874 }
else if (value.substr(0, 3) ==
"no_") {
2875 myRestrictionType = RestrictionType::NO;
2881 }
else if (key ==
"except") {
2885 myRestrictionException |=
SVC_BUS;
2886 }
else if (v ==
"bicycle") {
2888 }
else if (v ==
"hgv") {
2890 }
else if (v ==
"motorcar") {
2892 }
else if (v ==
"emergency") {
2896 }
else if (key ==
"public_transport") {
2898 if (value ==
"stop_area") {
2899 myIsStopArea =
true;
2901 }
else if (key ==
"route") {
2903 if (value ==
"train" || value ==
"subway" || value ==
"light_rail" || value ==
"monorail" || value ==
"tram" || value ==
"bus"
2904 || value ==
"trolleybus" || value ==
"aerialway" || value ==
"ferry" || value ==
"share_taxi" || value ==
"minibus") {
2905 myPTRouteType = value;
2908 }
else if (key ==
"name") {
2910 }
else if (key ==
"colour") {
2915 WRITE_WARNINGF(
TL(
"Invalid color value '%' in relation %"), value, myCurrentRelation);
2917 }
else if (key ==
"ref") {
2919 }
else if (key ==
"interval" || key ==
"headway") {
2921 }
else if (key ==
"by_night") {
2930 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
2941 if (myIsRestriction) {
2944 if (myRestrictionType == RestrictionType::UNKNOWN) {
2960 if (ok && !applyRestriction()) {
2963 }
else if (myIsStopArea) {
2964 for (
long long ref : myStops) {
2965 myStopAreas[ref] = myCurrentRelation;
2974 std::shared_ptr<NBPTStop> ptStop = myNBPTStopCont->get(
toString(n->
id));
2975 if (ptStop ==
nullptr) {
2982 if (myPlatform.isWay) {
2986 WRITE_WARNINGF(
TL(
"Platform '%' in relation: '%' is given as polygon, which currently is not supported."), myPlatform.ref, myCurrentRelation);
3001 WRITE_ERRORF(
"Unable to project coordinates for node '%'.", pNode->
id);
3004 p.push_back(pNodePos);
3006 if (p.size() == 0) {
3007 WRITE_WARNINGF(
TL(
"Referenced platform: '%' in relation: '%' is corrupt. Probably OSM file is incomplete."),
3012 ptStop->addPlatformCand(platform);
3023 WRITE_ERRORF(
"Unable to project coordinates for node '%'.", pNode->
id);
3025 NBPTPlatform platform(platformPos, myOptionsCont.getFloat(
"osm.stop-output.length"));
3026 ptStop->addPlatformCand(platform);
3030 ptStop->setIsMultipleStopPositions(myStops.size() > 1, myCurrentRelation);
3032 const auto& nodeIt =
myOSMNodes.find(myStation);
3035 if (station !=
nullptr) {
3043 }
else if (myPTRouteType !=
"" && myIsRoute) {
3044 NBPTLine* ptLine =
new NBPTLine(
toString(myCurrentRelation), myName, myPTRouteType, myRef, myInterval, myNightService,
3046 int consecutiveGap =
false;
3047 int missingBefore = 0;
3048 int missingAfter = 0;
3049 for (
long long ref : myStops) {
3061 if (consecutiveGap > 1) {
3062 WRITE_WARNINGF(
TL(
"PT line '%' in relation % has a gap of % stops, only keeping first part."), myName, myCurrentRelation, consecutiveGap);
3063 missingAfter = (int)myStops.size() - missingBefore - (int)ptLine->
getStops().size();
3069 const NIOSMNode*
const n = nodeIt->second;
3070 std::shared_ptr<NBPTStop> ptStop = myNBPTStopCont->get(
toString(n->
id));
3071 if (ptStop ==
nullptr) {
3075 WRITE_ERRORF(
"Unable to project coordinates for node '%'.", n->
id);
3079 myNBPTStopCont->insert(ptStop);
3080 if (myStopAreas.count(n->
id)) {
3081 ptStop->setIsMultipleStopPositions(
false, myStopAreas[n->
id]);
3083 if (myPlatformStops.count(n->
id) > 0) {
3084 ptStop->setIsPlatform();
3089 for (
long long& myWay : myWays) {
3090 auto entr = myOSMEdges.find(myWay);
3091 if (entr != myOSMEdges.end()) {
3092 Edge* edge = entr->second;
3098 ptLine->
setNumOfStops((
int)myStops.size(), missingBefore, missingAfter);
3100 WRITE_WARNINGF(
TL(
"PT line in relation % with no stops ignored. Probably OSM file is incomplete."), myCurrentRelation);
3105 if (!myNBPTLineCont->insert(ptLine)) {
3120 if (viaNode ==
nullptr) {
3126 if (from ==
nullptr) {
3130 if (to ==
nullptr) {
3134 if (myRestrictionType == RestrictionType::ONLY) {
3161 WRITE_WARNINGF(
TL(
"direction of restriction relation could not be determined%"),
"");
3169 const std::vector<NBEdge*>& candidates)
const {
3170 const std::string prefix =
toString(wayRef);
3171 const std::string backPrefix =
"-" + prefix;
3172 NBEdge* result =
nullptr;
3174 for (
auto candidate : candidates) {
3175 const std::string& cid = candidate->
getID();
3176 const bool matchFwd = (cid == prefix) || (cid.size() > prefix.size() && cid.compare(0, prefix.size(), prefix) == 0 && cid[prefix.size()] ==
'#');
3177 const bool matchBwd = (cid == backPrefix) || (cid.size() > backPrefix.size() && cid.compare(0, backPrefix.size(), backPrefix) == 0 && cid[backPrefix.size()] ==
'#');
3178 if (matchFwd || matchBwd) {
3184 WRITE_WARNINGF(
TL(
"Ambiguous way reference '%' in restriction relation"), prefix);
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
#define PROGRESS_TIME_MESSAGE(before)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
SVCPermissions extraDisallowed(SVCPermissions disallowed, const MMVersion &networkVersion)
Interprets disallowed vehicles depending on network version.
const SVCPermissions SVCAll
all VClasses are allowed
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a (exclusive) railway edge.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_SHIP
is an arbitrary ship
@ SVC_PRIVATE
private vehicles
@ SVC_TRUCK
vehicle is a large transport vehicle
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_RAIL_FAST
vehicle that is allowed to drive on high-speed rail tracks
@ SVC_TRAILER
vehicle is a large transport vehicle
@ SVC_RAIL_ELECTRIC
rail vehicle that requires electrified tracks
@ SVC_RAIL_URBAN
vehicle is a city rail
@ SVC_MOTORCYCLE
vehicle is a motorcycle
@ SVC_EMERGENCY
public emergency vehicles
@ SVC_MOPED
vehicle is a moped
@ SVC_AUTHORITY
authorities vehicles
@ SVC_TRAM
vehicle is a light rail
@ SVC_PUBLIC_CLASSES
public transport
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_NODE
alternative definition for junction
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ TURN
The link is a 180 degree turn.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ PARTRIGHT
The link is a partial right direction.
@ NODIR
The link has no direction (is a dead end link)
const double SUMO_const_laneWidth
std::string joinToStringSorting(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool isReadable(std::string path)
Checks whether the given file is readable.
void setFileName(const std::string &name)
Sets the current file name.
bool wasInformed() const
Returns the information whether any messages were added.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Storage for edges, including some functionality operating on multiple edges.
int extractRoundabouts()
Determines which edges have been marked as roundabouts and stores them internally.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
The representation of a single edge during network building.
static const int TURN_SIGN_SHIFT_BUS
shift values for decoding turn signs
static const int TURN_SIGN_SHIFT_BICYCLE
void setPermittedChanging(int lane, SVCPermissions changeLeft, SVCPermissions changeRight)
set allowed classes for changing to the left and right from the given lane
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connections
NBNode * getToNode() const
Returns the destination node of the edge.
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Lane & getLaneStruct(int lane)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false, SVCPermissions permission=SVC_UNSPECIFIED)
Adds a connection to another edge.
void setTurnSignTarget(const std::string &target)
void setDistance(double distance)
set kilometrage at start of edge (negative value implies couting down along the edge)
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
const std::string & getID() const
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connections
int getNumLanes() const
Returns the number of lanes.
void setRoundaboutGuessExcluded(bool excluded)
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)
bool isConnectedTo(const NBEdge *e, const bool ignoreTurnaround=false) const
Returns the information whethe a connection to the given edge has been added (or computed)
static const int TURN_SIGN_SHIFT_TAXI
void preferVehicleClass(int lane, SVCPermissions vclasses)
prefer certain vehicle classes for the given lane or for all lanes if -1 is given (ensures also permi...
NBNode * getFromNode() const
Returns the origin node of the edge.
static const double UNSPECIFIED_WIDTH
unspecified lane width
void setRoutingType(const std::string &routingType)
set the routingType for this edge
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
Instance responsible for building networks.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
NBParkingCont & getParkingCont()
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
Container for nodes during the netbuilding process.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Represents a single node (junction) during network building.
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
NBNode::Crossing * addCrossing(EdgeVector edges, double width, bool priority, int tlIndex=-1, int tlIndex2=-1, const PositionVector &customShape=PositionVector::EMPTY, bool fromSumoNet=false, const Parameterised *params=nullptr)
add a pedestrian crossing to this node
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
SumoXMLNodeType getType() const
Returns the type of this node.
void setRoundaboutType(RoundaboutType roundaboutType)
set roundabout type
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
bool checkCrossingDuplicated(EdgeVector edges)
return true if there already exist a crossing with the same edges as the input
const Position & getPosition() const
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
static const int FORWARD
edge directions (for pedestrian related stuff)
A traffic light logics which must be computed (only nodes/edges are given)
void setNumOfStops(int numStops, int missingBefore, int missingAfter)
void addWayNode(long long int way, long long int node)
const std::vector< std::shared_ptr< NBPTStop > > & getStops()
void addPTStop(std::shared_ptr< NBPTStop > pStop)
Container for public transport stops during the net building process.
const std::map< std::string, std::shared_ptr< NBPTStop > > & getStops() const
Returns an unmodifiable reference to the stored pt stops.
int cleanupDeleted(NBEdgeCont &cont, bool reAssign=false)
remove stops on non existing (removed) edges
std::shared_ptr< NBPTStop > get(std::string id) const
Retrieve a previously inserted pt stop.
bool insert(std::shared_ptr< NBPTStop > ptStop, bool floating=false)
Inserts a node into the map.
The representation of an imported parking area.
static const std::string OSM_DIRECTION
processing parameter for rail signal edges and nodes
static const std::string OSM_SIGNAL_DIRECTION
A container for traffic light definitions and built programs.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
A storage for available edgeTypes of edges.
bool getEdgeTypeShallBeDiscarded(const std::string &edgeType) const
Returns the information whether edges of this edgeType shall be discarded.
void insertEdgeType(const std::string &id, int numLanes, double maxSpeed, int prio, SVCPermissions permissions, LaneSpreadFunction spreadType, double width, bool oneWayIsDefault, double sidewalkWidth, double bikeLaneWidth, double widthResolution, double maxWidth, double minWidth)
Adds a edgeType into the list.
bool copyEdgeTypeRestrictionsAndAttrs(const std::string &fromId, const std::string &toId)
Copy restrictions to a edgeType.
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
double getEdgeTypeSidewalkWidth(const std::string &edgeType) const
Returns the lane width for a sidewalk to be added [m].
LaneSpreadFunction getEdgeTypeSpreadType(const std::string &edgeType) const
Returns spreadType for the given edgeType.
double getEdgeTypeBikeLaneWidth(const std::string &edgeType) const
Returns the lane width for a bike lane to be added [m].
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
Functor which compares two Edges.
bool operator()(const Edge *e1, const Edge *e2) const
An internal definition of a loaded edge.
DirLaneInfo myDirBackward
int myPlacementLane
1-based lane index for placement specification
std::vector< SVCPermissions > myDisallowedLaneBackward
(optional) information about additional disallowed SVCs on backward lane(s)
DirLaneInfo myDirForward
per-direction lane counts and bus/PSV lane metadata
std::map< std::string, std::string > myExtraTags
Additionally tagged information.
std::vector< double > myWidthLanesForward
Information on lane width.
WayType mySidewalkType
Information about the kind of sidwalk along this road.
std::vector< double > myWidthLanesBackward
int myNoLanesBothWays
explicitly tagged center two-way lane count, or 0 if unknown
std::vector< SVCPermissions > myDisallowedLaneForward
(optional) information about additional disallowed SVCs on forward lane(s)
bool myCurrentIsRoad
Information whether this is a road.
WayType myCyclewayType
Information about the kind of cycleway along this road.
std::vector< int > myTurnSignsBackward
SVCPermissions myOnewayContraPermissions
Vehicle classes exempted from oneway restriction via oneway:<mode>=no.
double myMaxSpeed
resolved forward maximum speed in m/s, or MAXSPEED_UNGIVEN
std::string ref
The edge's track name.
std::vector< SVCPermissions > myAllowedLaneForward
(optional) information about additional allowed SVCs on forward lane(s)
std::string myHighWayType
The type, stored in "highway" key.
const long long int id
The edge's id.
bool myAmInRoundabout
Information whether this road is part of a roundabout.
int myLayer
Information about the relative z-ordering of ways.
bool myRoundaboutGuessExcluded
Way metadata that rules out an inferred roundabout.
int myRailDirection
Information about the direction(s) of railway usage.
std::vector< bool > myDesignatedLaneBackward
(optional) information about whether the backward lanes are designated to some SVCs
SVCPermissions myExtraDisallowed
Extra permissions prohibited from tags instead of highway type.
double myMaxSpeedBase
direction-neutral base maximum speed (maxspeed / maxspeed:type / zone:maxspeed) in m/s,...
std::vector< SVCPermissions > myAllowedLaneBackward
(optional) information about additional allowed SVCs on backward lane(s)
int myNoLanes
number of lanes, or -1 if unknown
std::vector< int > myTurnSignsForward
turning direction (arrows printed on the road)
std::vector< long long int > myCurrentNodes
The list of nodes this edge is made of.
int myParkingType
Information about road-side parking.
double myMaxSpeedBackward
explicitly tagged backward maximum speed in m/s, or MAXSPEED_UNGIVEN
WayType myBuswayType
Information about the kind of busway along this road.
int myChangeForward
Information about change prohibitions (forward direction.
SVCPermissions myExtraAllowed
Extra permissions added from tags instead of highway type.
int myChangeBackward
Information about change prohibitions (backward direction.
std::string streetName
The edge's street name.
PlacementType myPlacement
placement of the OSM way geometry relative to lanes
bool myIsCircularJunction
Whether OSM explicitly classifies the way as a circular junction.
std::vector< bool > myDesignatedLaneForward
(optional) information about whether the forward lanes are designated to some SVCs
std::string myIsOneWay
Information whether this is an one-way road.
A class which extracts OSM-edges from a parsed OSM-file.
void addType(const std::string &singleTypeID)
void interpretLaneUse(const std::string &value, SUMOVehicleClass svc, const bool forward) const
int interpretChangeType(const std::string &value) const
EdgesHandler(const std::map< long long int, NIOSMNode * > &osmNodes, std::map< long long int, Edge * > &toFill, std::map< long long int, Edge * > &platformShapes, const NBTypeCont &tc)
Constructor.
~EdgesHandler() override
Destructor.
void myEndElement(int element) override
Called when a closing tag occurs.
bool interpretPlacement(const std::string &value, NIImporter_OpenStreetMap::PlacementType &placement, int &laneIndex) const
double interpretSpeed(const std::string &key, std::string value)
std::map< std::string, double > mySpeedMap
A map of non-numeric speed descriptions to their numeric values.
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
int parseBusLaneCount(const std::string &key, const std::string &value) const
A class which extracts OSM-nodes from a parsed OSM-file.
~NodesHandler() override
Destructor.
int getDuplicateNodes() const
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
NodesHandler(std::map< long long int, NIOSMNode * > &toFill, std::set< NIOSMNode *, CompareNodes > &uniqueNodes, const OptionsCont &cont)
Constructor.
void myEndElement(int element) override
Called when a closing tag occurs.
StringVector myRailSignalRules
custom requirements for rail signal tagging
A class which extracts relevant relation information from a parsed OSM-file.
void myEndElement(int element) override
Called when a closing tag occurs.
void resetValues()
reset members to their defaults for parsing a new relation
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
~RelationHandler() override
Destructor.
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.
bool checkEdgeRef(long long int ref) const
check whether a referenced way has a corresponding edge
bool applyRestriction() const
try to apply the parsed restriction and return whether successful
NBEdge * findEdgeRef(long long int wayRef, const std::vector< NBEdge * > &candidates) const
try to find the way segment among candidates
Importer for networks stored in OpenStreetMap format.
int insertEdge(Edge *e, int index, NBNode *from, NBNode *to, const std::vector< long long int > &passed, NBNetBuilder &nb, const NBNode *first, const NBNode *last)
Builds an NBEdge.
std::map< long long int, Edge * > myEdges
the map from OSM way ids to edge objects
bool myImportCrossings
import crossings
std::map< long long int, NIOSMNode * > myOSMNodes
the map from OSM node ids to actual nodes
NIImporter_OpenStreetMap()
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given OSM file.
static const long long int INVALID_ID
WayType
details on the kind of sidewalk, cycleway, busway along this road
void applyLaneUse(NBEdge *e, NIImporter_OpenStreetMap::Edge *nie, const bool forward)
Applies lane use information from nie to e.
static const double MAXSPEED_UNGIVEN
bool myOnewayDualSidewalk
import sidewalks
~NIImporter_OpenStreetMap()
std::map< long long int, Edge * > myPlatformShapes
the map from OSM way ids to platform shapes
void load(const OptionsCont &oc, NBNetBuilder &nb)
void applyTurnSigns(NBEdge *e, const std::vector< int > &turnSigns)
bool myImportSidewalks
import sidewalks
std::set< NIOSMNode *, CompareNodes > myUniqueNodes
the set of unique nodes used in NodesHandler, used when freeing memory
static bool myAllAttributes
whether additional way and node attributes shall be imported
void reconstructLayerElevation(double layerElevation, NBNetBuilder &nb)
reconstruct elevation from layer info
static SUMOVehicleClass interpretTransportType(const std::string &type, NIOSMNode *toSet=nullptr)
translate osm transport designations into sumo vehicle class
int myPlacementSkippedNonExplicitOneWay
number of placement skips due to non-explicit oneway
bool myImportLaneAccess
import lane specific access restrictions
bool myImportTurnSigns
import turning signals (turn:lanes) to guide connection building
std::map< std::string, std::string > myKnownCompoundTypes
The compound types that have already been mapped to other known types.
static const std::string compoundTypeSeparator
The separator within newly created compound type names.
std::set< std::string > myUnusableTypes
The compounds types that do not contain known types.
bool myETCS_movingBlock
whether ETCS signals default to moving block
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...
static std::set< std::string > myExtraAttributes
extra attributes to import
bool myImportBikeAccess
import bike path specific permissions and directions
bool myAnnotateDefaults
whether edges should carry information on the use of typemap defaults
static double interpretDistance(NIOSMNode *node)
read distance value from node and return value in m
NBNode * insertNodeChecking(long long int id, NBNodeCont &nc, NBTrafficLightLogicCont &tlsc)
Builds an NBNode.
static void mergeTurnSigns(std::vector< int > &signs, std::vector< int > signs2)
void extendRailwayDistances(Edge *e, NBTypeCont &tc)
extend kilometrage data for all nodes along railway
int myPlacementSkippedAuxOppositeDirection
number of placement skips due to generated opposite-direction auxiliary edges
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
static void applyChangeProhibition(NBEdge *e, int changeProhibition)
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
void unsetParameter(const std::string &key)
Removes a parameter.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
void updateParameters(const Parameterised::Map &mapArg)
Adds or updates all given parameters from the map.
A point in 2D or 3D with translation and scaling methods.
double length2D() const
Returns the length.
double length() const
Returns the length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
PositionVector reverse() const
reverse position vector
static RGBColor parseColor(std::string coldef)
Parses a color information.
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(const std::string &str) const
get key
int size() const
returns the number of existing substrings
std::vector< std::string > getVector()
return vector of strings
bool hasNext()
returns the information whether further substrings exist
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static bool isBool(const std::string &sData)
check if the given value can be converted to bool
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static double parseDist(const std::string &sData)
parse a distance, length or width value with a unit
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static double parseSpeed(const std::string &sData, const bool defaultKmph=true)
parse a speed value with a unit
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler, const bool isNet=false, const bool isRoute=false)
Builds a reader and assigns the handler to it.
An (internal) definition of a single lane of an edge.
int turnSigns
turning signs printed on the road, bitset of LinkDirection (imported from OSM)
Per-direction lane counts and bus/PSV lane metadata.
SVCPermissions busClasses
An internal representation of an OSM-node.
SVCPermissions permissions
type of pt stop
int railwaySignal
Whether this is a railway (main) signal.
NBNode * node
the NBNode that was instantiated
double positionMeters
position converted to m (using highest precision available)
const long long int id
The node's id.
bool pedestrianCrossing
Whether this is a pedestrian crossing.
bool tlsControlled
Whether this is a tls controlled junction.
double ptStopLength
The length of the pt stop.
bool ptStopPosition
Whether this is a public transport stop position.
std::string name
The name of the node.
bool railwayCrossing
Whether this is a railway crossing.
double ele
The elevation of this node.
bool railwayBufferStop
Whether this is a railway buffer stop.
const double lon
The longitude the node is located at.
const double lat
The latitude the node is located at.
WayType myRailDirection
Information about the direction(s) of railway usage.