55#define KM_PER_MILE 1.609344
106 importer.
load(oc, nb);
118 delete myEdge.second;
122 delete myPlatformShape.second;
128 if (!oc.
isSet(
"osm-files")) {
131 const std::vector<std::string> files = oc.
getStringVector(
"osm-files");
132 std::vector<SUMOSAXReader*> readers;
140 for (
const std::string& file : files) {
142 WRITE_ERROR(
"Could not open osm-file '" + file +
"'.");
149 if (!readers.back()->parseFirst(file) || !readers.back()->parseSection(
SUMO_TAG_NODE) ||
162 for (
const std::string& file : files) {
164 readers[idx]->setHandler(edgesHandler);
169 readers[idx] =
nullptr;
176 if (!oc.
getBool(
"osm.skip-duplicates-check")) {
180 std::set<const Edge*, CompareEdges> dupsFinder;
182 if (dupsFinder.count(it->second) > 0) {
187 dupsFinder.insert(it->second);
192 if (numRemoved > 0) {
201 std::map<long long int, int> nodeUsage;
203 for (std::map<long long int, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
204 Edge* e = (*i).second;
206 for (std::vector<long long int>::const_iterator j = e->
myCurrentNodes.begin();
209 if (nodeUsage.find(*j) == nodeUsage.end()) {
212 nodeUsage[*j] = nodeUsage[*j] + 1;
216 for (std::map<long long int, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin();
219 if (nodesIt->second->tlsControlled || nodesIt->second->railwaySignal ) {
222 nodeUsage[nodesIt->first] += 1;
232 Edge* e = myEdge.second;
244 NBNode* currentFrom = first;
246 std::vector<long long int> passed;
248 passed.push_back(*j);
251 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb, first, last);
252 currentFrom = currentTo;
254 passed.push_back(*j);
260 insertEdge(e, running, currentFrom, last, passed, nb, first, last);
263 const double layerElevation = oc.
getFloat(
"osm.layer-elevation");
264 if (layerElevation > 0) {
276 for (
const std::string& file : files) {
277 if (readers[idx] !=
nullptr) {
279 readers[idx]->setHandler(relationHandler);
289 std::set<std::string> stopNames;
291 stopNames.insert(item.second->getName());
310 if (node ==
nullptr) {
335 if (!tlsc.
insert(tlDef)) {
352 const std::vector<long long int>& passed,
NBNetBuilder& nb,
362 if (from ==
nullptr || to ==
nullptr) {
363 WRITE_ERROR(
"Discarding edge '" +
id +
"' because the nodes could not be built.");
372 assert(passed.size() >= 2);
373 if (passed.size() == 2) {
374 WRITE_WARNINGF(
TL(
"Discarding edge '%' which connects two identical nodes without geometry."),
id);
378 int intermediateIndex = (int) passed.size() / 2;
380 std::vector<long long int> part1(passed.begin(), passed.begin() + intermediateIndex + 1);
381 std::vector<long long int> part2(passed.begin() + intermediateIndex, passed.end());
382 index =
insertEdge(e, index, from, intermediate, part1, nb, first, last);
383 return insertEdge(e, index, intermediate, to, part2, nb, first, last);
385 const int newIndex = index + 1;
397 permissions &= ~e->myExtraDisallowed;
399 defaultsToOneWay =
false;
407 double distanceStart =
myOSMNodes[passed.front()]->positionMeters;
408 double distanceEnd =
myOSMNodes[passed.back()]->positionMeters;
409 const bool useDistance = distanceStart != std::numeric_limits<double>::max() && distanceEnd != std::numeric_limits<double>::max();
412 if (distanceStart < distanceEnd) {
421 std::vector<NBPTStop*> ptStops;
422 for (
long long i : passed) {
427 if (existingPtStop !=
nullptr) {
435 sc.
insert(ptStops.back());
439 shape.push_back(pos);
442 WRITE_ERROR(
"Unable to project coordinates for edge '" +
id +
"'.");
448 if (streetName == e->
ref) {
466 bool addForward =
true;
467 bool addBackward =
true;
493 if (addForward && !addBackward) {
495 }
else if (!addForward && addBackward) {
503 numLanesForward = (int) std::ceil(e->
myNoLanes / 2.0);
505 numLanesBackward = e->
myNoLanes - numLanesForward;
508 numLanesForward =
MAX2(1, numLanesForward);
509 numLanesBackward =
MAX2(1, numLanesBackward);
527 double speedBackward = speed;
531 if (speed <= 0 || speedBackward <= 0) {
538 if (!addForward && (cyclewayType &
WAY_FORWARD) != 0) {
546 if (!addBackward && (cyclewayType &
WAY_BACKWARD) != 0) {
550 numLanesBackward = 1;
562 if (!addForward && (sidewalkType &
WAY_FORWARD) != 0) {
569 }
else if (addSidewalk && addForward && (sidewalkType &
WAY_BOTH) == 0
570 && numLanesForward == 1 && numLanesBackward <= 1
577 if (!addBackward && (sidewalkType &
WAY_BACKWARD) != 0) {
581 numLanesBackward = 1;
584 }
else if (addSidewalk && addBackward && (sidewalkType &
WAY_BOTH) == 0
585 && numLanesBackward == 1 && numLanesForward <= 1
602 numLanesBackward = 1;
615 const std::string reverseID =
"-" + id;
618 assert(numLanesForward > 0);
648 assert(numLanesBackward > 0);
674 throw ProcessError(
"Could not add edge '-" +
id +
"'.");
710 std::set<NIOSMNode*, CompareNodes>& uniqueNodes,
const OptionsCont& oc) :
713 myCurrentNode(nullptr),
715 myUniqueNodes(uniqueNodes),
716 myImportElevation(oc.getBool(
"osm.elevation")),
729 if (myHierarchyLevel != 2) {
730 WRITE_ERROR(
"Node element on wrong XML hierarchy level (id='" + myLastNodeID +
731 "', level='" +
toString(myHierarchyLevel) +
"').");
735 if (action ==
"delete" || !ok) {
741 myCurrentNode =
nullptr;
742 const auto insertionIt = myToFill.lower_bound(
id);
743 if (insertionIt == myToFill.end() || insertionIt->first !=
id) {
745 const double tlon = attrs.
get<
double>(
SUMO_ATTR_LON, myLastNodeID.c_str(), ok);
746 const double tlat = attrs.
get<
double>(
SUMO_ATTR_LAT, myLastNodeID.c_str(), ok);
750 myCurrentNode =
new NIOSMNode(
id, tlon, tlat);
755 delete myCurrentNode;
756 myCurrentNode = *similarNode;
759 myToFill.emplace_hint(insertionIt,
id, myCurrentNode);
762 WRITE_ERROR(
TL(
"Attribute 'id' in the definition of a node is not of type long long int."));
766 if (element ==
SUMO_TAG_TAG && myCurrentNode !=
nullptr) {
767 if (myHierarchyLevel != 3) {
768 WRITE_ERROR(
TL(
"Tag element on wrong XML hierarchy level."));
772 const std::string& key = attrs.
get<std::string>(
SUMO_ATTR_K, myLastNodeID.c_str(), ok,
false);
774 if (key ==
"highway" || key ==
"ele" || key ==
"crossing" || key ==
"railway" || key ==
"public_transport"
775 || key ==
"name" || key ==
"train" || key ==
"bus" || key ==
"tram" || key ==
"light_rail" || key ==
"subway" || key ==
"station" || key ==
"noexit"
779 const std::string& value = attrs.
get<std::string>(
SUMO_ATTR_V, myLastNodeID.c_str(), ok,
false);
780 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
781 myCurrentNode->tlsControlled =
true;
782 }
else if (key ==
"crossing" && value.find(
"traffic_signals") != std::string::npos) {
783 myCurrentNode->tlsControlled =
true;
784 }
else if ((key ==
"noexit" && value ==
"yes")
785 || (key ==
"railway" && value ==
"buffer_stop")) {
786 myCurrentNode->railwayBufferStop =
true;
787 }
else if (key ==
"railway" && value.find(
"crossing") != std::string::npos) {
788 myCurrentNode->railwayCrossing =
true;
790 value ==
"block" || value ==
"entry" || value ==
"exit" || value ==
"intermediate")) {
791 myCurrentNode->railwaySignal =
true;
792 }
else if (
StringUtils::startsWith(key,
"railway:position") && value.size() > myCurrentNode->position.size()) {
794 myCurrentNode->position = value;
795 }
else if ((key ==
"public_transport" && value ==
"stop_position") ||
796 (key ==
"highway" && value ==
"bus_stop")) {
797 myCurrentNode->ptStopPosition =
true;
798 if (myCurrentNode->ptStopLength == 0) {
800 myCurrentNode->ptStopLength = myOptionsCont.getFloat(
"osm.stop-output.length");
802 }
else if (key ==
"name") {
803 myCurrentNode->name = value;
804 }
else if (myImportElevation && key ==
"ele") {
807 if (
ISNAN(elevation)) {
808 WRITE_WARNINGF(
TL(
"Value of key '%' is invalid ('%') in node '%'."), key, value, myLastNodeID);
810 myCurrentNode->ele = elevation;
813 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in node '%'."), key, value, myLastNodeID);
815 }
else if (key ==
"station") {
829 myCurrentNode =
nullptr;
839 const std::map<long long int, NIOSMNode*>& osmNodes,
840 std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes):
844 myPlatformShapesMap(platformShapes) {
947 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
949 if (action ==
"delete" || !ok) {
950 myCurrentEdge =
nullptr;
953 myCurrentEdge =
new Edge(
id);
956 if (element ==
SUMO_TAG_ND && myCurrentEdge !=
nullptr) {
966 ref = node->second->id;
967 if (myCurrentEdge->myCurrentNodes.empty() ||
968 myCurrentEdge->myCurrentNodes.back() != ref) {
969 myCurrentEdge->myCurrentNodes.push_back(ref);
974 if (element ==
SUMO_TAG_TAG && myCurrentEdge !=
nullptr) {
979 const std::string cyclewaySpec = key.substr(9);
981 if (cyclewaySpec ==
"right") {
982 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType |
WAY_FORWARD);
983 }
else if (cyclewaySpec ==
"left") {
985 }
else if (cyclewaySpec ==
"both") {
986 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType |
WAY_BOTH);
990 if ((myCurrentEdge->myCyclewayType &
WAY_BOTH) != 0) {
992 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType & ~
WAY_UNKNOWN);
996 const std::string buswaySpec = key.substr(7);
998 if (buswaySpec ==
"right") {
1000 }
else if (buswaySpec ==
"left") {
1002 }
else if (buswaySpec ==
"both") {
1003 myCurrentEdge->myBuswayType = (
WayType)(myCurrentEdge->myBuswayType |
WAY_BOTH);
1008 if (myAllAttributes && (myExtraAttributes.count(key) != 0 || myExtraAttributes.size() == 0)) {
1009 const std::string info =
"way=" +
toString(myCurrentEdge->id) +
", k=" + key;
1010 myCurrentEdge->setParameter(key, attrs.
get<std::string>(
SUMO_ATTR_V, info.c_str(), ok,
false));
1014 && key !=
"maxspeed" && key !=
"maxspeed:type"
1015 && key !=
"zone:maxspeed"
1016 && key !=
"maxspeed:forward" && key !=
"maxspeed:backward"
1017 && key !=
"junction" && key !=
"name" && key !=
"tracks" && key !=
"layer"
1019 && key !=
"sidewalk"
1021 && key !=
"highspeed"
1025 && key !=
"postal_code"
1026 && key !=
"railway:preferred_direction"
1027 && key !=
"railway:bidirectional"
1028 && key !=
"railway:track_ref"
1030 && key !=
"electrified"
1035 && key !=
"oneway:bicycle"
1037 && key !=
"public_transport") {
1042 if ((key ==
"highway" && value !=
"platform") || key ==
"railway" || key ==
"waterway" || key ==
"cycleway"
1043 || key ==
"busway" || key ==
"route" || key ==
"sidewalk" || key ==
"highspeed"
1044 || key ==
"aeroway" || key ==
"aerialway" || key ==
"usage") {
1046 std::string singleTypeID = key +
"." + value;
1047 myCurrentEdge->myCurrentIsRoad =
true;
1049 if (key ==
"cycleway") {
1050 if (value ==
"no") {
1053 if (value ==
"opposite_track") {
1055 }
else if (value ==
"opposite_lane") {
1060 if (key ==
"sidewalk") {
1061 if (value ==
"no" || value ==
"none") {
1062 myCurrentEdge->mySidewalkType =
WAY_NONE;
1063 }
else if (value ==
"both") {
1064 myCurrentEdge->mySidewalkType =
WAY_BOTH;
1065 }
else if (value ==
"right") {
1067 }
else if (value ==
"left") {
1074 if (key ==
"busway") {
1075 if (value ==
"no") {
1078 if (value ==
"opposite_track") {
1080 }
else if (value ==
"opposite_lane") {
1086 if (key ==
"highspeed") {
1087 if (value ==
"no") {
1090 singleTypeID =
"railway.highspeed";
1093 if (!myCurrentEdge->myHighWayType.empty() && singleTypeID !=
"railway.highspeed") {
1094 if (myCurrentEdge->myHighWayType ==
"railway.highspeed") {
1099 std::vector<std::string> types =
StringTokenizer(myCurrentEdge->myHighWayType,
1101 types.push_back(singleTypeID);
1104 myCurrentEdge->myHighWayType = singleTypeID;
1106 }
else if (key ==
"bus" || key ==
"psv") {
1110 myCurrentEdge->myExtraAllowed |=
SVC_BUS;
1112 myCurrentEdge->myExtraDisallowed |=
SVC_BUS;
1115 myCurrentEdge->myExtraAllowed |=
SVC_BUS;
1117 }
else if (key ==
"foot") {
1118 if (value ==
"use_sidepath" || value ==
"no") {
1120 }
else if (value ==
"yes" || value ==
"designated" || value ==
"permissive") {
1123 }
else if (key ==
"bicycle") {
1124 if (myImportBikeAccess) {
1125 if (value ==
"use_sidepath" || value ==
"no") {
1127 }
else if (value ==
"yes" || value ==
"designated" || value ==
"permissive") {
1131 }
else if (key ==
"oneway:bicycle") {
1132 if (myImportBikeAccess) {
1133 if (value ==
"true" || value ==
"yes" || value ==
"1") {
1136 if (value ==
"-1" || value ==
"reverse") {
1140 if (value ==
"no" || value ==
"false" || value ==
"0") {
1141 myCurrentEdge->myCyclewayType =
WAY_BOTH;
1144 }
else if (key ==
"lanes") {
1150 std::vector<std::string> list = st.
getVector();
1151 if (list.size() >= 2) {
1152 int minLanes = std::numeric_limits<int>::max();
1154 for (
auto& i : list) {
1156 minLanes =
MIN2(minLanes, numLanes);
1158 myCurrentEdge->myNoLanes = minLanes;
1161 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
1165 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
1167 }
else if (key ==
"lanes:forward") {
1170 if (myCurrentEdge->myNoLanesForward < 0 && myCurrentEdge->myNoLanes < 0) {
1172 myCurrentEdge->myNoLanes = numLanes - myCurrentEdge->myNoLanesForward;
1174 myCurrentEdge->myNoLanesForward = numLanes;
1176 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
1178 }
else if (key ==
"lanes:backward") {
1181 if (myCurrentEdge->myNoLanesForward > 0 && myCurrentEdge->myNoLanes < 0) {
1183 myCurrentEdge->myNoLanes = numLanes + myCurrentEdge->myNoLanesForward;
1186 myCurrentEdge->myNoLanesForward = -numLanes;
1188 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
1191 (key ==
"maxspeed" || key ==
"maxspeed:type" || key ==
"maxspeed:forward" || key ==
"zone:maxspeed")) {
1193 myCurrentEdge->myMaxSpeed = interpretSpeed(key, value);
1194 }
else if (key ==
"maxspeed:backward" && myCurrentEdge->myMaxSpeedBackward ==
MAXSPEED_UNGIVEN) {
1195 myCurrentEdge->myMaxSpeedBackward = interpretSpeed(key, value);
1196 }
else if (key ==
"junction") {
1197 if ((value ==
"roundabout" || value ==
"circular") && (myCurrentEdge->myIsOneWay.empty())) {
1198 myCurrentEdge->myIsOneWay =
"yes";
1200 }
else if (key ==
"oneway") {
1201 myCurrentEdge->myIsOneWay = value;
1202 }
else if (key ==
"name") {
1203 myCurrentEdge->streetName = value;
1204 }
else if (key ==
"ref") {
1205 myCurrentEdge->ref = value;
1206 myCurrentEdge->setParameter(
"ref", value);
1207 }
else if (key ==
"layer") {
1211 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
1213 }
else if (key ==
"tracks") {
1216 myCurrentEdge->myIsOneWay =
"true";
1218 WRITE_WARNINGF(
TL(
"Ignoring track count % for edge '%'."), value, myCurrentEdge->id);
1221 WRITE_WARNINGF(
TL(
"Value of key '%' is not numeric ('%') in edge '%'."), key, value, myCurrentEdge->id);
1223 }
else if (key ==
"railway:preferred_direction") {
1224 if (value ==
"both") {
1225 myCurrentEdge->myRailDirection =
WAY_BOTH;
1226 }
else if (value ==
"backward") {
1229 }
else if (key ==
"railway:bidirectional") {
1230 if (value ==
"regular") {
1231 myCurrentEdge->myRailDirection =
WAY_BOTH;
1233 }
else if (key ==
"electrified") {
1234 if (value !=
"no") {
1235 myCurrentEdge->myCurrentIsElectrified =
true;
1237 }
else if (key ==
"railway:track_ref") {
1238 myCurrentEdge->setParameter(key, value);
1239 }
else if (key ==
"public_transport" && value ==
"platform") {
1240 myCurrentEdge->myCurrentIsPlatform =
true;
1247 }
else if (key ==
"change" || key ==
"change:lanes") {
1248 myCurrentEdge->myChangeForward = myCurrentEdge->myChangeBackward = interpretChangeType(value);
1249 }
else if (key ==
"change:forward" || key ==
"change:lanes:forward") {
1250 myCurrentEdge->myChangeForward = interpretChangeType(value);
1251 }
else if (key ==
"change:backward" || key ==
"change:lanes:backward") {
1252 myCurrentEdge->myChangeBackward = interpretChangeType(value);
1253 }
else if (key ==
"vehicle:lanes" || key ==
"vehicle:lanes:forward") {
1254 interpretLaneUse(value,
SVC_PASSENGER, myCurrentEdge->myLaneUseForward);
1255 }
else if (key ==
"vehicle:lanes:backward") {
1256 interpretLaneUse(value,
SVC_PASSENGER, myCurrentEdge->myLaneUseBackward);
1259 std::vector<int> turnCodes;
1260 for (std::string codeList : values) {
1263 for (std::string code : codes) {
1264 if (code ==
"" || code ==
"none" || code ==
"through") {
1266 }
else if (code ==
"left" || code ==
"sharp_left") {
1268 }
else if (code ==
"right" || code ==
"sharp_right") {
1270 }
else if (code ==
"slight_left") {
1272 }
else if (code ==
"slight_right") {
1274 }
else if (code ==
"reverse") {
1276 }
else if (code ==
"merge_to_left" || code ==
"merge_to_right") {
1280 turnCodes.push_back(turnCode);
1282 if (key ==
"turn:lanes" || key ==
"turn:lanes:forward") {
1283 myCurrentEdge->myTurnSignsForward = turnCodes;
1284 }
else if (key ==
"turn:lanes:backward") {
1285 myCurrentEdge->myTurnSignsBackward = turnCodes;
1286 }
else if (key ==
"turn:lanes:both_ways") {
1287 myCurrentEdge->myTurnSignsForward = turnCodes;
1288 myCurrentEdge->myTurnSignsBackward = turnCodes;
1297 if (mySpeedMap.find(value) != mySpeedMap.end()) {
1298 return mySpeedMap[value];
1301 if (value.size() > 3 && value[2] ==
':') {
1302 if (value.substr(3, 4) ==
"zone") {
1303 value = value.substr(7);
1305 value = value.substr(3);
1308 double conversion = 1;
1318 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1319 toString(myCurrentEdge->id) +
"'.");
1330 for (
const std::string& val : values) {
1333 }
else if (val ==
"not_left") {
1335 }
else if (val ==
"not_right") {
1338 result = result << 2;
1341 result = result >> 2;
1343 if (values.size() > 1) {
1355 for (
const std::string& val : values) {
1357 if (val ==
"yes" || val ==
"lane" || val ==
"designated") {
1359 }
else if (val !=
"no") {
1360 WRITE_WARNINGF(
TL(
"Unknown lane use specifier '%' treated as 'no' for way '%'"), val, myCurrentEdge->id);
1362 if (i >= (
int)result.size()) {
1363 result.push_back(use);
1374 if (element ==
SUMO_TAG_WAY && myCurrentEdge !=
nullptr) {
1375 if (myCurrentEdge->myCurrentIsRoad) {
1376 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
1377 }
else if (myCurrentEdge->myCurrentIsPlatform) {
1378 myPlatformShapesMap[myCurrentEdge->id] = myCurrentEdge;
1380 delete myCurrentEdge;
1382 myCurrentEdge =
nullptr;
1391 const std::map<long long int, NIOSMNode*>& osmNodes,
1392 const std::map<long long int, Edge*>& osmEdges,
NBPTStopCont* nbptStopCont,
1393 const std::map<long long int, Edge*>& platformShapes,
1398 myOSMEdges(osmEdges),
1400 myNBPTStopCont(nbptStopCont),
1401 myNBPTLineCont(nbptLineCont),
1413 myIsRestriction =
false;
1418 myRestrictionType = RestrictionType::UNKNOWN;
1419 myPlatforms.clear();
1421 myPlatformStops.clear();
1423 myIsStopArea =
false;
1426 myRouteColor.setValid(
false);
1434 myCurrentRelation = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
1436 if (action ==
"delete" || !ok) {
1442 myNightService =
"";
1451 const long long int ref = attrs.
get<
long long int>(
SUMO_ATTR_REF,
nullptr, ok);
1452 if (role ==
"via") {
1455 if (memberType ==
"way" && checkEdgeRef(ref)) {
1457 }
else if (memberType ==
"node") {
1464 }
else if (role ==
"from" && checkEdgeRef(ref)) {
1466 }
else if (role ==
"to" && checkEdgeRef(ref)) {
1468 }
else if (role ==
"stop") {
1469 myStops.push_back(ref);
1470 }
else if (role ==
"platform") {
1472 if (memberType ==
"way") {
1473 const std::map<long long int, NIImporter_OpenStreetMap::Edge*>::const_iterator& wayIt =
myPlatformShapes.find(ref);
1476 platform.
isWay =
true;
1478 myPlatforms.push_back(platform);
1480 }
else if (memberType ==
"node") {
1482 myStops.push_back(ref);
1483 myPlatformStops.insert(ref);
1485 platform.
isWay =
false;
1487 myPlatforms.push_back(platform);
1490 }
else if (role.empty()) {
1492 if (memberType ==
"way") {
1493 myWays.push_back(ref);
1494 }
else if (memberType ==
"node") {
1495 myStops.push_back(ref);
1505 if (key ==
"type" || key ==
"restriction") {
1507 if (key ==
"type" && value ==
"restriction") {
1508 myIsRestriction =
true;
1511 if (key ==
"type" && value ==
"route") {
1515 if (key ==
"restriction") {
1518 if (value.substr(0, 5) ==
"only_") {
1519 myRestrictionType = RestrictionType::ONLY;
1520 }
else if (value.substr(0, 3) ==
"no_") {
1521 myRestrictionType = RestrictionType::NO;
1527 }
else if (key ==
"public_transport") {
1529 if (value ==
"stop_area") {
1530 myIsStopArea =
true;
1532 }
else if (key ==
"route") {
1534 if (value ==
"train" || value ==
"subway" || value ==
"light_rail" || value ==
"monorail" || value ==
"tram" || value ==
"bus"
1535 || value ==
"trolleybus" || value ==
"aerialway" || value ==
"ferry" || value ==
"share_taxi" || value ==
"minibus") {
1536 myPTRouteType = value;
1539 }
else if (key ==
"name") {
1541 }
else if (key ==
"colour") {
1546 WRITE_WARNINGF(
TL(
"Invalid color value '%' in relation %"), value, myCurrentRelation);
1548 }
else if (key ==
"ref") {
1550 }
else if (key ==
"interval" || key ==
"headway") {
1552 }
else if (key ==
"by_night") {
1561 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
1572 if (myIsRestriction) {
1575 if (myRestrictionType == RestrictionType::UNKNOWN) {
1591 if (ok && !applyRestriction()) {
1594 }
else if (myIsStopArea) {
1595 for (
long long ref : myStops) {
1596 myStopAreas[ref] = myCurrentRelation;
1606 if (ptStop ==
nullptr) {
1613 if (myPlatform.isWay) {
1617 WRITE_WARNINGF(
TL(
"Platform '%' in relation: '%' is given as polygon, which currently is not supported."), myPlatform.ref, myCurrentRelation);
1635 p.push_back(pNodePos);
1637 if (p.size() == 0) {
1638 WRITE_WARNINGF(
TL(
"Referenced platform: '%' in relation: '%' is corrupt. Probably OSM file is incomplete."),
1656 NBPTPlatform platform(platformPos, myOptionsCont.getFloat(
"osm.stop-output.length"));
1663 }
else if (myPTRouteType !=
"" && myIsRoute) {
1664 NBPTLine* ptLine =
new NBPTLine(
toString(myCurrentRelation), myName, myPTRouteType, myRef, myInterval, myNightService,
1667 bool hadGap =
false;
1668 for (
long long ref : myStops) {
1671 if (!ptLine->
getStops().empty() && !hadGap) {
1677 WRITE_WARNINGF(
TL(
"PT line '%' in relation % seems to be split, only keeping first part."), myName, myCurrentRelation);
1681 const NIOSMNode*
const n = nodeIt->second;
1683 if (ptStop ==
nullptr) {
1690 myNBPTStopCont->insert(ptStop);
1691 if (myStopAreas.count(n->
id)) {
1694 if (myPlatformStops.count(n->
id) > 0) {
1700 for (
long long& myWay : myWays) {
1701 auto entr = myOSMEdges.find(myWay);
1702 if (entr != myOSMEdges.end()) {
1703 Edge* edge = entr->second;
1710 WRITE_WARNINGF(
TL(
"PT line in relation % with no stops ignored. Probably OSM file is incomplete."), myCurrentRelation);
1714 if (myNBPTLineCont->getLines().count(ptLine->
getLineID()) == 0) {
1715 myNBPTLineCont->insert(ptLine);
1731 if (viaNode ==
nullptr) {
1737 if (from ==
nullptr) {
1741 if (to ==
nullptr) {
1745 if (myRestrictionType == RestrictionType::ONLY) {
1759 WRITE_WARNINGF(
TL(
"direction of restriction relation could not be determined%"),
"");
1767 const std::vector<NBEdge*>& candidates)
const {
1768 const std::string prefix =
toString(wayRef);
1769 const std::string backPrefix =
"-" + prefix;
1770 NBEdge* result =
nullptr;
1772 for (
auto candidate : candidates) {
1773 if ((candidate->getID().substr(0, prefix.size()) == prefix) ||
1774 (candidate->getID().substr(0, backPrefix.size()) == backPrefix)) {
1780 WRITE_WARNINGF(
TL(
"Ambiguous way reference '%' in restriction relation"), prefix);
1794 std::map<NBNode*, std::vector<std::pair<double, double> > > layerForces;
1797 std::set<NBNode*> knownElevation;
1798 for (
auto& myEdge :
myEdges) {
1799 Edge* e = myEdge.second;
1803 if (node !=
nullptr) {
1804 knownElevation.insert(node);
1805 layerForces[node].emplace_back(e->
myLayer * layerElevation, POSITION_EPS);
1810#ifdef DEBUG_LAYER_ELEVATION
1811 std::cout <<
"known elevations:\n";
1812 for (std::set<NBNode*>::iterator it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1813 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1814 std::cout <<
" node=" << (*it)->
getID() <<
" ele=";
1815 for (std::vector<std::pair<double, double> >::const_iterator it_ele = primaryLayers.begin(); it_ele != primaryLayers.end(); ++it_ele) {
1816 std::cout << it_ele->first <<
" ";
1824 std::map<NBNode*, double> knownEleMax;
1825 for (
auto it : knownElevation) {
1826 double eleMax = -std::numeric_limits<double>::max();
1827 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[it];
1828 for (
const auto& primaryLayer : primaryLayers) {
1829 eleMax =
MAX2(eleMax, primaryLayer.first);
1831 knownEleMax[it] = eleMax;
1834 bool changed =
true;
1837 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1840 / gradeThreshold * 3,
1842 for (
auto& neighbor : neighbors) {
1843 if (knownElevation.count(neighbor.first) != 0) {
1844 const double grade = fabs(knownEleMax[*it] - knownEleMax[neighbor.first])
1845 /
MAX2(POSITION_EPS, neighbor.second.first);
1846#ifdef DEBUG_LAYER_ELEVATION
1847 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";
1849 if (grade > gradeThreshold * 50 / 3.6 / neighbor.second.second) {
1851 const double eleMax =
MAX2(knownEleMax[*it], knownEleMax[neighbor.first]);
1852 if (knownEleMax[*it] < eleMax) {
1853 knownEleMax[*it] = eleMax;
1855 knownEleMax[neighbor.first] = eleMax;
1865 std::set<NBNode*> unknownElevation;
1866 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1867 const double eleMax = knownEleMax[*it];
1868 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1869 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1870 for (
auto& neighbor : neighbors) {
1871 if (knownElevation.count(neighbor.first) == 0) {
1872 unknownElevation.insert(neighbor.first);
1873 layerForces[neighbor.first].emplace_back(eleMax, neighbor.second.first);
1879 for (
auto it = unknownElevation.begin(); it != unknownElevation.end(); ++it) {
1880 double eleMax = -std::numeric_limits<double>::max();
1881 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1882 for (
const auto& primaryLayer : primaryLayers) {
1883 eleMax =
MAX2(eleMax, primaryLayer.first);
1885 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1886 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1887 for (
auto& neighbor : neighbors) {
1888 if (knownElevation.count(neighbor.first) == 0 && unknownElevation.count(neighbor.first) == 0) {
1889 layerForces[*it].emplace_back(0, neighbor.second.first);
1894#ifdef DEBUG_LAYER_ELEVATION
1895 std::cout <<
"summation of forces\n";
1897 std::map<NBNode*, double> nodeElevation;
1898 for (
auto& layerForce : layerForces) {
1899 const std::vector<std::pair<double, double> >& forces = layerForce.second;
1900 if (knownElevation.count(layerForce.first) != 0) {
1908#ifdef DEBUG_LAYER_ELEVATION
1909 std::cout <<
" node=" << it->first->getID() <<
" knownElevation=" << knownEleMax[it->first] <<
"\n";
1911 nodeElevation[layerForce.first] = knownEleMax[layerForce.first];
1912 }
else if (forces.size() == 1) {
1913 nodeElevation[layerForce.first] = forces.front().first;
1917 for (
const auto& force : forces) {
1918 distSum += force.second;
1920 double weightSum = 0;
1921 double elevation = 0;
1922#ifdef DEBUG_LAYER_ELEVATION
1923 std::cout <<
" node=" << it->first->getID() <<
" distSum=" << distSum <<
"\n";
1925 for (
const auto& force : forces) {
1926 const double weight = (distSum - force.second) / distSum;
1927 weightSum += weight;
1928 elevation += force.first * weight;
1930#ifdef DEBUG_LAYER_ELEVATION
1931 std::cout <<
" force=" << it_force->first <<
" dist=" << it_force->second <<
" weight=" << weight <<
" ele=" << elevation <<
"\n";
1934 nodeElevation[layerForce.first] = elevation / weightSum;
1937#ifdef DEBUG_LAYER_ELEVATION
1938 std::cout <<
"final elevations:\n";
1939 for (std::map<NBNode*, double>::iterator it = nodeElevation.begin(); it != nodeElevation.end(); ++it) {
1940 std::cout <<
" node=" << (it->first)->getID() <<
" ele=" << it->second <<
"\n";
1944 for (
auto& it : nodeElevation) {
1951 for (
const auto& it : ec) {
1952 NBEdge* edge = it.second;
1954 const double length = geom.
length2D();
1955 const double zFrom = nodeElevation[edge->
getFromNode()];
1956 const double zTo = nodeElevation[edge->
getToNode()];
1961 for (
auto it_pos = geom.begin(); it_pos != geom.end(); ++it_pos) {
1962 if (it_pos != geom.begin()) {
1963 dist += (*it_pos).distanceTo2D(*(it_pos - 1));
1965 newGeom.push_back((*it_pos) +
Position(0, 0, zFrom + (zTo - zFrom) * dist / length));
1971std::map<NBNode*, std::pair<double, double> >
1973 std::map<NBNode*, std::pair<double, double> > result;
1974 std::set<NBNode*> visited;
1975 std::vector<NBNode*> open;
1976 open.push_back(node);
1977 result[node] = std::make_pair(0, 0);
1978 while (!open.empty()) {
1981 if (visited.count(n) != 0) {
1986 for (
auto e : edges) {
1989 s = e->getFromNode();
1993 const double dist = result[n].first + e->getGeometry().length2D();
1994 const double speed =
MAX2(e->getSpeed(), result[n].second);
1995 if (result.count(s) == 0) {
1996 result[s] = std::make_pair(dist, speed);
1998 result[s] = std::make_pair(
MIN2(dist, result[s].first),
MAX2(speed, result[s].second));
2000 if (dist < maxDist && knownElevation.count(s) == 0) {
2012 if (tc.
knows(type)) {
2023 std::vector<std::string> types;
2025 std::string t = tok.
next();
2027 if (std::find(types.begin(), types.end(), t) == types.end()) {
2030 }
else if (tok.
size() > 1) {
2031 WRITE_WARNINGF(
TL(
"Discarding unknown compound '%' in type '%' (first occurence for edge '%')."), t, type,
id);
2034 if (types.empty()) {
2035 WRITE_WARNINGF(
TL(
"Discarding unusable type '%' (first occurence for edge '%')."), type,
id);
2040 if (tc.
knows(newType)) {
2048 double maxSpeed = 0;
2053 bool defaultIsOneWay =
true;
2056 bool discard =
true;
2057 for (
auto& type2 : types) {
2084 WRITE_WARNINGF(
TL(
"Discarding compound type '%' (first occurence for edge '%')."), newType,
id);
2089 WRITE_MESSAGE(
"Adding new type '" + type +
"' (first occurence for edge '" +
id +
"').");
2090 tc.
insertEdgeType(newType, numLanes, maxSpeed, prio, permissions, spreadType, width,
2091 defaultIsOneWay, sidewalkWidth, bikelaneWidth, 0, 0, 0);
2092 for (
auto& type3 : types) {
2107 std::vector<NIOSMNode*> nodes;
2108 std::vector<double> usablePositions;
2109 std::vector<int> usableIndex;
2113 if (node->
positionMeters != std::numeric_limits<double>::max()) {
2115 usableIndex.push_back((
int)nodes.size());
2117 nodes.push_back(node);
2119 if (usablePositions.size() == 0) {
2122 bool forward =
true;
2123 if (usablePositions.size() == 1) {
2124 WRITE_WARNINGF(
TL(
"Ambiguous railway kilometrage direction for way '%' (assuming forward)"),
id);
2126 forward = usablePositions.front() < usablePositions.back();
2129 for (
int i = 1; i < (int)usablePositions.size(); i++) {
2130 if ((usablePositions[i - 1] < usablePositions[i]) != forward) {
2131 WRITE_WARNINGF(
TL(
"Inconsistent railway kilometrage direction for way '%': % (skipping)"),
id,
toString(usablePositions));
2135 if (nodes.size() > usablePositions.size()) {
2139 shape.push_back(
Position(node->lon, node->lat, 0));
2144 double sign = forward ? 1 : -1;
2146 for (
int i = usableIndex.front() - 1; i >= 0; i--) {
2147 nodes[i]->positionMeters = nodes[i + 1]->positionMeters - sign * shape[i].distanceTo2D(shape[i + 1]);
2150 for (
int i = usableIndex.front() + 1; i < (
int)nodes.size(); i++) {
2151 if (nodes[i]->positionMeters == std::numeric_limits<double>::max()) {
2152 nodes[i]->positionMeters = nodes[i - 1]->positionMeters + sign * shape[i].distanceTo2D(shape[i - 1]);
2179 return std::numeric_limits<double>::max();
2185 if (type ==
"train") {
2187 }
else if (type ==
"subway" || type ==
"light_rail" || type ==
"monorail" || type ==
"aerialway") {
2189 }
else if (type ==
"share_taxi") {
2191 }
else if (type ==
"minibus") {
2196 std::string stop =
"";
2199 }
else if (result ==
SVC_BUS) {
2213 bool multiLane = changeProhibition > 3;
2215 for (
int lane = 0; changeProhibition > 0 && lane < e->
getNumLanes(); lane++) {
2216 int code = changeProhibition % 4;
2221 changeProhibition = changeProhibition >> 2;
2231 for (
int lane = 0; lane < (int)laneUse.size(); lane++) {
2233 const int i = lefthand ? lane : e->
getNumLanes() - 1 - lane;
2235 if (laneUse[i] == 0) {
2238 svc &= ~SVC_PASSENGER;
2255 for (
int i = 0; i < (int)turnSigns.size(); i++) {
2257 const int laneIndex = lefthand ? i : e->
getNumLanes() - 1 - i;
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
#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
const SVCPermissions SVCAll
all VClasses are allowed
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
bool isBikepath(SVCPermissions permissions)
Returns whether an edge with the given permission is a bicycle edge.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_ROAD_CLASSES
classes which drive on roads
@ 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_RAIL_ELECTRIC
rail vehicle that requires electrified tracks
@ SVC_RAIL_URBAN
vehicle is a city rail
@ SVC_AUTHORITY
authorities vehicles
@ SVC_TRAM
vehicle is a light rail
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ 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.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
The representation of a single edge during network building.
bool addEdge2EdgeConnection(NBEdge *dest, bool overrideRemoval=false)
Adds a connection to another edge.
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 connctions
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.
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::string & getID() const
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
int getNumLanes() const
Returns the number of lanes.
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)
NBNode * getFromNode() const
Returns the origin node of the edge.
static const double UNSPECIFIED_WIDTH
unspecified lane width
static const double UNSPECIFIED_OFFSET
unspecified lane offset
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.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
SumoXMLNodeType getType() const
Returns the type of this node.
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)
const Position & getPosition() const
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
void setFringeType(FringeType fringeType)
set method for computing right-of-way
A traffic light logics which must be computed (only nodes/edges are given)
void addPTStop(NBPTStop *pStop)
const std::vector< NBPTStop * > & getStops()
const std::string & getLineID() const
void addWayNode(long long int way, long long int node)
void setMyNumOfStops(int numStops)
bool insert(NBPTStop *ptStop, bool floating=false)
Inserts a node into the map.
int cleanupDeleted(NBEdgeCont &cont)
remove stops on non existing (removed) edges
NBPTStop * get(std::string id) const
Retrieve a previously inserted pt stop.
const std::map< std::string, NBPTStop * > & getStops() const
The representation of a single pt stop.
void registerAdditionalEdge(std::string wayId, std::string edgeId)
void addPlatformCand(NBPTPlatform platform)
void setIsMultipleStopPositions(bool multipleStopPositions, long long int areaID)
The representation of an imported parking area.
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.
WayType mySidewalkType
Information about the kind of sidwalk along this road.
std::vector< SVCPermissions > myLaneUseForward
(optional) information about the permitted vehicle classes on each lane
bool myCurrentIsRoad
Information whether this is a road.
WayType myCyclewayType
Information about the kind of cycleway along this road.
std::vector< int > myTurnSignsBackward
int myNoLanesForward
number of lanes in forward direction or 0 if unknown, negative if backwards lanes are meant
double myMaxSpeed
maximum speed in km/h, or MAXSPEED_UNGIVEN
bool myCurrentIsElectrified
Information whether this is railway is electrified.
std::string ref
The edge's track name.
std::string myHighWayType
The type, stored in "highway" key.
const long long int id
The edge's id.
int myLayer
Information about the relative z-ordering of ways.
SVCPermissions myExtraDisallowed
Extra permissions prohibited from tags instead of highway type.
std::vector< SVCPermissions > myLaneUseBackward
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
maximum speed in km/h, 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.
WayType myRailDirection
Information about the direction(s) of railway usage.
std::string myIsOneWay
Information whether this is an one-way road.
A class which extracts OSM-edges from a parsed OSM-file.
std::set< std::string > myExtraAttributes
extra attributes to import
EdgesHandler(const std::map< long long int, NIOSMNode * > &osmNodes, std::map< long long int, Edge * > &toFill, std::map< long long int, Edge * > &platformShapes)
Constructor.
int interpretChangeType(const std::string &value) const
~EdgesHandler() override
Destructor.
bool myAllAttributes
whether additional way attributes shall be added to the edge
bool myImportBikeAccess
import bike path specific permissions and directions
void myEndElement(int element) override
Called when a closing tag occurs.
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;.
void interpretLaneUse(const std::string &value, SUMOVehicleClass svc, std::vector< SVCPermissions > &result) 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)
Contructor.
void myEndElement(int element) override
Called when a closing tag occurs.
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
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
static const double MAXSPEED_UNGIVEN
~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
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
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.
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 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.
void extendRailwayDistances(Edge *e, NBTypeCont &tc)
extend kilometrage data for all nodes along railway
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
void applyLaneUseInformation(NBEdge *e, const std::vector< SVCPermissions > &laneUse)
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.
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.
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
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 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 std::string to_lower_case(const std::string &str)
Transfers the content to lower case.
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 bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
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)
An internal representation of an OSM-node.
SVCPermissions permissions
type of pt stop
NBNode * node
the NBNode that was instantiated
double positionMeters
position converted to m (using highest precision available)
std::string position
kilometrage/mileage
const long long int id
The node's id.
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.
bool railwaySignal
Whether this is a railway (main) signal.