54 #define KM_PER_MILE 1.609344
105 importer.
load(oc, nb);
117 delete myEdge.second;
121 delete myPlatformShape.second;
128 if (!oc.
isSet(
"osm-files")) {
141 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
144 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
159 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
168 if (!oc.
getBool(
"osm.skip-duplicates-check")) {
172 std::set<const Edge*, CompareEdges> dupsFinder;
174 if (dupsFinder.count(it->second) > 0) {
179 dupsFinder.insert(it->second);
184 if (numRemoved > 0) {
193 std::map<long long int, int> nodeUsage;
195 for (std::map<long long int, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
196 Edge* e = (*i).second;
198 for (std::vector<long long int>::const_iterator j = e->
myCurrentNodes.begin();
201 if (nodeUsage.find(*j) == nodeUsage.end()) {
204 nodeUsage[*j] = nodeUsage[*j] + 1;
208 for (std::map<long long int, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin();
211 if (nodesIt->second->tlsControlled || nodesIt->second->railwaySignal ) {
214 nodeUsage[nodesIt->first] += 1;
224 Edge* e = myEdge.second;
236 NBNode* currentFrom = first;
238 std::vector<long long int> passed;
240 passed.push_back(*j);
243 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb, first, last);
244 currentFrom = currentTo;
246 passed.push_back(*j);
252 insertEdge(e, running, currentFrom, last, passed, nb, first, last);
255 const double layerElevation = oc.
getFloat(
"osm.layer-elevation");
256 if (layerElevation > 0) {
269 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
281 if (node ==
nullptr) {
306 if (!tlsc.
insert(tlDef)) {
321 const std::vector<long long int>& passed,
NBNetBuilder& nb,
331 if (from ==
nullptr || to ==
nullptr) {
332 WRITE_ERROR(
"Discarding edge '" +
id +
"' because the nodes could not be built.");
341 assert(passed.size() >= 2);
342 if (passed.size() == 2) {
343 WRITE_WARNINGF(
"Discarding edge '%' which connects two identical nodes without geometry.",
id);
347 int intermediateIndex = (int) passed.size() / 2;
349 std::vector<long long int> part1(passed.begin(), passed.begin() + intermediateIndex + 1);
350 std::vector<long long int> part2(passed.begin() + intermediateIndex, passed.end());
351 index =
insertEdge(e, index, from, intermediate, part1, nb, first, last);
352 return insertEdge(e, index, intermediate, to, part2, nb, first, last);
354 const int newIndex = index + 1;
358 double distanceStart =
myOSMNodes[passed.front()]->positionMeters;
359 double distanceEnd =
myOSMNodes[passed.back()]->positionMeters;
360 const bool useDistance = distanceStart != std::numeric_limits<double>::max() && distanceEnd != std::numeric_limits<double>::max();
363 if (distanceStart < distanceEnd) {
372 for (
long long i : passed) {
376 if (existingPtStop !=
nullptr) {
390 shape.push_back(pos);
393 WRITE_ERROR(
"Unable to project coordinates for edge '" +
id +
"'.");
410 defaultsToOneWay =
false;
418 if (streetName == e->
ref) {
436 bool addForward =
true;
437 bool addBackward =
true;
462 if (addForward && !addBackward) {
464 }
else if (!addForward && addBackward) {
472 numLanesForward = (int) std::ceil(e->
myNoLanes / 2.0);
474 numLanesBackward = e->
myNoLanes - numLanesForward;
477 numLanesForward =
MAX2(1, numLanesForward);
478 numLanesBackward =
MAX2(1, numLanesBackward);
481 WRITE_WARNINGF(
"Skipping edge '%' because it has zero lanes.",
id);
496 double speedBackward = speed;
500 if (speed <= 0 || speedBackward <= 0) {
501 WRITE_WARNINGF(
"Skipping edge '%' because it has speed %.",
id, speed);
507 if (!addForward && (cyclewayType &
WAY_FORWARD) != 0) {
515 if (!addBackward && (cyclewayType &
WAY_BACKWARD) != 0) {
519 numLanesBackward = 1;
531 if (!addForward && (sidewalkType &
WAY_FORWARD) != 0) {
538 }
else if (addSidewalk && addForward && (sidewalkType &
WAY_BOTH) == 0
539 && numLanesForward == 1 && numLanesBackward <= 1
546 if (!addBackward && (sidewalkType &
WAY_BACKWARD) != 0) {
550 numLanesBackward = 1;
553 }
else if (addSidewalk && addBackward && (sidewalkType &
WAY_BOTH) == 0
554 && numLanesBackward == 1 && numLanesForward <= 1
571 numLanesBackward = 1;
584 const std::string reverseID =
"-" + id;
587 assert(numLanesForward > 0);
617 assert(numLanesBackward > 0);
643 throw ProcessError(
"Could not add edge '-" +
id +
"'.");
678 std::set<NIOSMNode*, CompareNodes>& uniqueNodes,
685 myIsInValidNodeTag(false),
687 myUniqueNodes(uniqueNodes),
688 myImportElevation(oc.getBool(
"osm.elevation")),
700 if (myHierarchyLevel != 2) {
705 +
"', level='" +
toString(myHierarchyLevel) +
"').");
708 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
710 if (action ==
"delete" || !ok) {
714 if (myToFill.find(
id) == myToFill.end()) {
738 auto* toAdd =
new NIOSMNode(
id, tlon, tlat);
739 myIsInValidNodeTag =
true;
746 toAdd = *similarNode;
749 myToFill[id] = toAdd;
753 if (myHierarchyLevel != 3) {
754 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
760 if (key ==
"highway" || key ==
"ele" || key ==
"crossing" || key ==
"railway" || key ==
"public_transport"
761 || key ==
"name" || key ==
"train" || key ==
"bus" || key ==
"tram" || key ==
"light_rail" || key ==
"subway" || key ==
"station" || key ==
"noexit"
766 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
767 myToFill[myLastNodeID]->tlsControlled =
true;
768 }
else if (key ==
"crossing" && value.find(
"traffic_signals") != std::string::npos) {
769 myToFill[myLastNodeID]->tlsControlled =
true;
770 }
else if ((key ==
"noexit" && value ==
"yes")
771 || (key ==
"railway" && value ==
"buffer_stop")) {
772 myToFill[myLastNodeID]->railwayBufferStop =
true;
773 }
else if (key ==
"railway" && value.find(
"crossing") != std::string::npos) {
774 myToFill[myLastNodeID]->railwayCrossing =
true;
776 value ==
"block" || value ==
"entry" || value ==
"exit" || value ==
"intermediate")) {
777 myToFill[myLastNodeID]->railwaySignal =
true;
778 }
else if (
StringUtils::startsWith(key,
"railway:position") && value.size() > myToFill[myLastNodeID]->position.size()) {
780 myToFill[myLastNodeID]->position = value;
781 }
else if ((key ==
"public_transport" && value ==
"stop_position") ||
782 (key ==
"highway" && value ==
"bus_stop")) {
783 myToFill[myLastNodeID]->ptStopPosition =
true;
784 if (myToFill[myLastNodeID]->ptStopLength == 0) {
786 myToFill[myLastNodeID]->ptStopLength = myOptionsCont.getFloat(
"osm.stop-output.length");
788 }
else if (key ==
"name") {
789 myToFill[myLastNodeID]->name = value;
790 }
else if (myImportElevation && key ==
"ele") {
793 if (
ISNAN(elevation)) {
796 myToFill[myLastNodeID]->ele = elevation;
801 }
else if (key ==
"station") {
815 myIsInValidNodeTag =
false;
824 const std::map<long long int, NIOSMNode*>& osmNodes,
825 std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes):
829 myPlatformShapesMap(platformShapes) {
928 myParentElements.push_back(element);
932 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
934 if (action ==
"delete" || !ok) {
935 myCurrentEdge =
nullptr;
938 myCurrentEdge =
new Edge(
id);
941 if (element ==
SUMO_TAG_ND && myCurrentEdge !=
nullptr) {
951 ref = node->second->id;
952 if (myCurrentEdge->myCurrentNodes.empty() ||
953 myCurrentEdge->myCurrentNodes.back() != ref) {
954 myCurrentEdge->myCurrentNodes.push_back(ref);
960 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2
961 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
962 if (myCurrentEdge ==
nullptr) {
969 const std::string cyclewaySpec = key.substr(9);
971 if (cyclewaySpec ==
"right") {
972 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType |
WAY_FORWARD);
973 }
else if (cyclewaySpec ==
"left") {
975 }
else if (cyclewaySpec ==
"both") {
976 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType |
WAY_BOTH);
980 if ((myCurrentEdge->myCyclewayType &
WAY_BOTH) != 0) {
982 myCurrentEdge->myCyclewayType = (
WayType)(myCurrentEdge->myCyclewayType & ~
WAY_UNKNOWN);
986 const std::string buswaySpec = key.substr(7);
988 if (buswaySpec ==
"right") {
990 }
else if (buswaySpec ==
"left") {
992 }
else if (buswaySpec ==
"both") {
993 myCurrentEdge->myBuswayType = (
WayType)(myCurrentEdge->myBuswayType |
WAY_BOTH);
998 if (myAllAttributes && (myExtraAttributes.count(key) != 0 || myExtraAttributes.size() == 0)) {
999 const std::string info =
"way=" +
toString(myCurrentEdge->id) +
", k=" + key;
1000 myCurrentEdge->setParameter(key, attrs.
get<std::string>(
SUMO_ATTR_V, info.c_str(), ok,
false));
1004 && key !=
"maxspeed" && key !=
"maxspeed:type"
1005 && key !=
"maxspeed:forward" && key !=
"maxspeed:backward"
1006 && key !=
"junction" && key !=
"name" && key !=
"tracks" && key !=
"layer"
1008 && key !=
"sidewalk"
1010 && key !=
"highspeed"
1014 && key !=
"postal_code"
1015 && key !=
"railway:preferred_direction"
1016 && key !=
"railway:bidirectional"
1017 && key !=
"railway:track_ref"
1019 && key !=
"electrified"
1024 && key !=
"oneway:bicycle"
1026 && key !=
"public_transport") {
1031 if ((key ==
"highway" && value !=
"platform") || key ==
"railway" || key ==
"waterway" || key ==
"cycleway"
1032 || key ==
"busway" || key ==
"route" || key ==
"sidewalk" || key ==
"highspeed"
1033 || key ==
"aeroway" || key ==
"usage") {
1035 std::string singleTypeID = key +
"." + value;
1036 myCurrentEdge->myCurrentIsRoad =
true;
1038 if (key ==
"cycleway") {
1039 if (value ==
"no") {
1042 if (value ==
"opposite_track") {
1044 }
else if (value ==
"opposite_lane") {
1049 if (key ==
"sidewalk") {
1050 if (value ==
"no" || value ==
"none") {
1051 myCurrentEdge->mySidewalkType =
WAY_NONE;
1052 }
else if (value ==
"both") {
1053 myCurrentEdge->mySidewalkType =
WAY_BOTH;
1054 }
else if (value ==
"right") {
1056 }
else if (value ==
"left") {
1063 if (key ==
"busway") {
1064 if (value ==
"no") {
1067 if (value ==
"opposite_track") {
1069 }
else if (value ==
"opposite_lane") {
1075 if (key ==
"highspeed") {
1076 if (value ==
"no") {
1079 singleTypeID =
"railway.highspeed";
1082 if (!myCurrentEdge->myHighWayType.empty() && singleTypeID !=
"railway.highspeed") {
1083 if (myCurrentEdge->myHighWayType ==
"railway.highspeed") {
1088 std::vector<std::string> types =
StringTokenizer(myCurrentEdge->myHighWayType,
1090 types.push_back(singleTypeID);
1093 myCurrentEdge->myHighWayType = singleTypeID;
1095 }
else if (key ==
"bus" || key ==
"psv") {
1099 myCurrentEdge->myExtraAllowed |=
SVC_BUS;
1101 myCurrentEdge->myExtraDisallowed |=
SVC_BUS;
1104 myCurrentEdge->myExtraAllowed |=
SVC_BUS;
1106 }
else if (key ==
"foot") {
1107 if (value ==
"use_sidepath" || value ==
"no") {
1109 }
else if (value ==
"yes" || value ==
"designated" || value ==
"permissive") {
1112 }
else if (key ==
"bicycle") {
1113 if (myImportBikeAccess) {
1114 if (value ==
"use_sidepath" || value ==
"no") {
1116 }
else if (value ==
"yes" || value ==
"designated" || value ==
"permissive") {
1120 }
else if (key ==
"oneway:bicycle") {
1121 if (myImportBikeAccess) {
1122 if (value ==
"true" || value ==
"yes" || value ==
"1") {
1125 if (value ==
"-1" || value ==
"reverse") {
1129 if (value ==
"no" || value ==
"false" || value ==
"0") {
1130 myCurrentEdge->myCyclewayType =
WAY_BOTH;
1133 }
else if (key ==
"lanes") {
1139 std::vector<std::string> list = st.
getVector();
1140 if (list.size() >= 2) {
1141 int minLanes = std::numeric_limits<int>::max();
1143 for (
auto& i : list) {
1145 minLanes =
MIN2(minLanes, numLanes);
1147 myCurrentEdge->myNoLanes = minLanes;
1148 WRITE_WARNINGF(
"Using minimum lane number from list (%) for edge '%'.", value,
toString(myCurrentEdge->id));
1150 WRITE_WARNINGF(
"Value of key '%' is not numeric ('%') in edge '%'.", key, value, myCurrentEdge->id);
1154 WRITE_WARNINGF(
"Value of key '%' is not numeric ('%') in edge '%'.", key, value, myCurrentEdge->id);
1156 }
else if (key ==
"lanes:forward") {
1159 if (myCurrentEdge->myNoLanesForward < 0 && myCurrentEdge->myNoLanes < 0) {
1161 myCurrentEdge->myNoLanes = numLanes - myCurrentEdge->myNoLanesForward;
1163 myCurrentEdge->myNoLanesForward = numLanes;
1165 WRITE_WARNINGF(
"Value of key '%' is not numeric ('%') in edge '%'.", key, value, myCurrentEdge->id);
1167 }
else if (key ==
"lanes:backward") {
1170 if (myCurrentEdge->myNoLanesForward > 0 && myCurrentEdge->myNoLanes < 0) {
1172 myCurrentEdge->myNoLanes = numLanes + myCurrentEdge->myNoLanesForward;
1175 myCurrentEdge->myNoLanesForward = -numLanes;
1177 WRITE_WARNINGF(
"Value of key '%' is not numeric ('%') in edge '%'.", key, value, myCurrentEdge->id);
1180 (key ==
"maxspeed" || key ==
"maxspeed:type" || key ==
"maxspeed:forward")) {
1182 myCurrentEdge->myMaxSpeed = interpretSpeed(key, value);
1183 }
else if (key ==
"maxspeed:backward" && myCurrentEdge->myMaxSpeedBackward ==
MAXSPEED_UNGIVEN) {
1184 myCurrentEdge->myMaxSpeedBackward = interpretSpeed(key, value);
1185 }
else if (key ==
"junction") {
1186 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay.empty())) {
1187 myCurrentEdge->myIsOneWay =
"yes";
1189 }
else if (key ==
"oneway") {
1190 myCurrentEdge->myIsOneWay = value;
1191 }
else if (key ==
"name") {
1192 myCurrentEdge->streetName = value;
1193 }
else if (key ==
"ref") {
1194 myCurrentEdge->ref = value;
1195 myCurrentEdge->setParameter(
"ref", value);
1196 }
else if (key ==
"layer") {
1200 WRITE_WARNINGF(
"Value of key '%' is not numeric ('%') in edge '%'.", key, value, myCurrentEdge->id);
1202 }
else if (key ==
"tracks") {
1205 myCurrentEdge->myIsOneWay =
"true";
1207 WRITE_WARNINGF(
"Ignoring track count % for edge '%'.", value, myCurrentEdge->id);
1210 WRITE_WARNINGF(
"Value of key '%' is not numeric ('%') in edge '%'.", key, value, myCurrentEdge->id);
1212 }
else if (key ==
"railway:preferred_direction") {
1213 if (value ==
"both") {
1214 myCurrentEdge->myRailDirection =
WAY_BOTH;
1215 }
else if (value ==
"backward") {
1218 }
else if (key ==
"railway:bidirectional") {
1219 if (value ==
"regular") {
1220 myCurrentEdge->myRailDirection =
WAY_BOTH;
1222 }
else if (key ==
"electrified") {
1223 if (value !=
"no") {
1224 myCurrentEdge->myCurrentIsElectrified =
true;
1226 }
else if (key ==
"railway:track_ref") {
1227 myCurrentEdge->setParameter(key, value);
1228 }
else if (key ==
"public_transport" && value ==
"platform") {
1229 myCurrentEdge->myCurrentIsPlatform =
true;
1236 }
else if (key ==
"change") {
1237 myCurrentEdge->myChangeForward = interpretChangeType(value);
1238 myCurrentEdge->myChangeBackward = myCurrentEdge->myChangeForward;
1239 }
else if (key ==
"change:forward") {
1240 myCurrentEdge->myChangeForward = interpretChangeType(value);
1241 }
else if (key ==
"change:backward") {
1242 myCurrentEdge->myChangeBackward = interpretChangeType(value);
1243 }
else if (key ==
"change:lanes") {
1244 myCurrentEdge->myChangeForward = interpretChangeType(value);
1245 }
else if (key ==
"change:lanes:forward") {
1246 myCurrentEdge->myChangeForward = interpretChangeType(value);
1247 }
else if (key ==
"change:lanes:backward") {
1248 myCurrentEdge->myChangeBackward = interpretChangeType(value);
1249 }
else if (key ==
"vehicle:lanes" || key ==
"vehicle:lanes:forward") {
1250 interpretLaneUse(value,
SVC_PASSENGER, myCurrentEdge->myLaneUseForward);
1251 }
else if (key ==
"vehicle:lanes:backward") {
1252 interpretLaneUse(value,
SVC_PASSENGER, myCurrentEdge->myLaneUseBackward);
1255 std::vector<int> turnCodes;
1256 for (std::string codeList : values) {
1259 for (std::string code : codes) {
1260 if (code ==
"" || code ==
"none" || code ==
"through") {
1262 }
else if (code ==
"left" || code ==
"sharp_left") {
1264 }
else if (code ==
"right" || code ==
"sharp_right") {
1266 }
else if (code ==
"slight_left") {
1268 }
else if (code ==
"slight_right") {
1270 }
else if (code ==
"reverse") {
1272 }
else if (code ==
"merge_to_left" || code ==
"merge_to_right") {
1276 turnCodes.push_back(turnCode);
1278 if (key ==
"turn:lanes" || key ==
"turn:lanes:forward") {
1279 myCurrentEdge->myTurnSignsForward = turnCodes;
1280 }
else if (key ==
"turn:lanes:backward") {
1281 myCurrentEdge->myTurnSignsBackward = turnCodes;
1282 }
else if (key ==
"turn:lanes:both_ways") {
1283 myCurrentEdge->myTurnSignsForward = turnCodes;
1284 myCurrentEdge->myTurnSignsBackward = turnCodes;
1293 if (mySpeedMap.find(value) != mySpeedMap.end()) {
1294 return mySpeedMap[value];
1296 double conversion = 1;
1306 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
1307 toString(myCurrentEdge->id) +
"'.");
1317 for (
const std::string& val : values) {
1320 }
else if (val ==
"not_left") {
1322 }
else if (val ==
"not_right") {
1325 result = result << 2;
1328 result = result >> 2;
1330 if (values.size() > 1) {
1342 for (
const std::string& val : values) {
1344 if (val ==
"yes" || val ==
"lane" || val ==
"designated") {
1346 }
else if (val !=
"no") {
1347 WRITE_WARNINGF(
"Unknown lane use specifier '%' treated as 'no' for way '%'", val, myCurrentEdge->id);
1349 if (i >= (
int)result.size()) {
1350 result.push_back(use);
1361 myParentElements.pop_back();
1362 if (element ==
SUMO_TAG_WAY && myCurrentEdge !=
nullptr) {
1363 if (myCurrentEdge->myCurrentIsRoad) {
1364 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
1365 }
else if (myCurrentEdge->myCurrentIsPlatform) {
1366 myPlatformShapesMap[myCurrentEdge->id] = myCurrentEdge;
1368 delete myCurrentEdge;
1370 myCurrentEdge =
nullptr;
1378 const std::map<long long int, NIOSMNode*>& osmNodes,
1379 const std::map<long long int, Edge*>& osmEdges,
NBPTStopCont* nbptStopCont,
1380 const std::map<long long int, Edge*>& platformShapes,
1385 myOSMEdges(osmEdges),
1387 myNBPTStopCont(nbptStopCont),
1388 myNBPTLineCont(nbptLineCont),
1398 myIsRestriction =
false;
1403 myRestrictionType = RestrictionType::UNKNOWN;
1404 myPlatforms.clear();
1406 myPlatformStops.clear();
1408 myIsStopArea =
false;
1411 myRouteColor.setValid(
false);
1417 myParentElements.push_back(element);
1421 myCurrentRelation = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
1423 if (action ==
"delete" || !ok) {
1429 myNightService =
"";
1439 auto ref = attrs.
get<
long
1442 if (role ==
"via") {
1445 if (memberType ==
"way" && checkEdgeRef(ref)) {
1447 }
else if (memberType ==
"node") {
1454 }
else if (role ==
"from" && checkEdgeRef(ref)) {
1456 }
else if (role ==
"to" && checkEdgeRef(ref)) {
1458 }
else if (role ==
"stop") {
1459 myStops.push_back(ref);
1460 }
else if (role ==
"platform") {
1462 if (memberType ==
"way") {
1463 const std::map<
long long int,
1468 platform.
isWay =
true;
1470 myPlatforms.push_back(platform);
1472 }
else if (memberType ==
"node") {
1474 myStops.push_back(ref);
1475 myPlatformStops.insert(ref);
1477 platform.
isWay =
false;
1479 myPlatforms.push_back(platform);
1482 }
else if (role.empty()) {
1484 if (memberType ==
"way") {
1485 myWays.push_back(ref);
1486 }
else if (memberType ==
"node") {
1487 myStops.push_back(ref);
1497 if (key ==
"type" || key ==
"restriction") {
1499 if (key ==
"type" && value ==
"restriction") {
1500 myIsRestriction =
true;
1503 if (key ==
"type" && value ==
"route") {
1507 if (key ==
"restriction") {
1510 if (value.substr(0, 5) ==
"only_") {
1511 myRestrictionType = RestrictionType::ONLY;
1512 }
else if (value.substr(0, 3) ==
"no_") {
1513 myRestrictionType = RestrictionType::NO;
1515 WRITE_WARNINGF(
"Found unknown restriction type '%' in relation '%'", value,
toString(myCurrentRelation));
1519 }
else if (key ==
"public_transport") {
1521 if (value ==
"stop_area") {
1522 myIsStopArea =
true;
1524 }
else if (key ==
"route") {
1526 if (value ==
"train" || value ==
"subway" || value ==
"light_rail" || value ==
"monorail" || value ==
"tram" || value ==
"bus"
1527 || value ==
"trolleybus" || value ==
"arialway" || value ==
"ferry" || value ==
"share_taxi" || value ==
"minibus") {
1528 myPTRouteType = value;
1531 }
else if (key ==
"name") {
1533 }
else if (key ==
"colour") {
1538 WRITE_WARNINGF(
"Invalid color value '%' in relation %", value, myCurrentRelation);
1540 }
else if (key ==
"ref") {
1542 }
else if (key ==
"interval" || key ==
"headway") {
1544 }
else if (key ==
"by_night") {
1552 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
1563 myParentElements.pop_back();
1565 if (myIsRestriction) {
1568 if (myRestrictionType == RestrictionType::UNKNOWN) {
1584 if (ok && !applyRestriction()) {
1588 for (
long long ref : myStops) {
1589 myStopAreas[ref] = myCurrentRelation;
1599 if (ptStop ==
nullptr) {
1606 if (myPlatform.isWay) {
1610 WRITE_WARNINGF(
"Platform '%' in relation: '%' is given as polygon, which currently is not supported.", myPlatform.ref, myCurrentRelation);
1628 p.push_back(pNodePos);
1630 if (p.size() == 0) {
1631 WRITE_WARNINGF(
"Referenced platform: '%' in relation: '%' is corrupt. Probably OSM file is incomplete.",
1649 NBPTPlatform platform(platformPos, myOptionsCont.getFloat(
1650 "osm.stop-output.length"));
1658 NBPTLine* ptLine =
new NBPTLine(
toString(myCurrentRelation), myName, myPTRouteType, myRef, myInterval, myNightService,
1661 for (
long long ref : myStops) {
1669 WRITE_WARNINGF(
"Done reading first coherent chunk of pt stops. Further stops in relation % are ignored", myCurrentRelation);
1677 if (ptStop ==
nullptr) {
1684 myNBPTStopCont->insert(ptStop);
1685 if (myStopAreas.count(n->
id)) {
1688 if (myPlatformStops.count(n->
id) > 0) {
1694 for (
long long& myWay : myWays) {
1695 auto entr = myOSMEdges.find(myWay);
1696 if (entr != myOSMEdges.end()) {
1697 Edge* edge = entr->second;
1704 WRITE_WARNINGF(
"PT line in relation % with no stops ignored. Probably OSM file is incomplete.", myCurrentRelation);
1708 if (myNBPTLineCont->getLines().count(ptLine->
getLineID()) == 0) {
1709 myNBPTLineCont->insert(ptLine);
1725 if (viaNode ==
nullptr) {
1731 if (from ==
nullptr) {
1735 if (to ==
nullptr) {
1739 if (myRestrictionType == RestrictionType::ONLY) {
1753 WRITE_WARNINGF(
"direction of restriction relation could not be determined%",
"");
1761 const std::vector<NBEdge*>& candidates)
const {
1762 const std::string prefix =
toString(wayRef);
1763 const std::string backPrefix =
"-" + prefix;
1764 NBEdge* result =
nullptr;
1766 for (
auto candidate : candidates) {
1767 if ((candidate->getID().substr(0, prefix.size()) == prefix) ||
1768 (candidate->getID().substr(0, backPrefix.size()) == backPrefix)) {
1774 WRITE_WARNINGF(
"Ambiguous way reference '%' in restriction relation", prefix);
1788 std::map<NBNode*, std::vector<std::pair<double, double> > > layerForces;
1791 std::set<NBNode*> knownElevation;
1792 for (
auto& myEdge :
myEdges) {
1793 Edge* e = myEdge.second;
1797 if (node !=
nullptr) {
1798 knownElevation.insert(node);
1799 layerForces[node].emplace_back(e->
myLayer * layerElevation, POSITION_EPS);
1804 #ifdef DEBUG_LAYER_ELEVATION
1805 std::cout <<
"known elevations:\n";
1806 for (std::set<NBNode*>::iterator it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1807 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1808 std::cout <<
" node=" << (*it)->
getID() <<
" ele=";
1809 for (std::vector<std::pair<double, double> >::const_iterator it_ele = primaryLayers.begin(); it_ele != primaryLayers.end(); ++it_ele) {
1810 std::cout << it_ele->first <<
" ";
1818 std::map<NBNode*, double> knownEleMax;
1819 for (
auto it : knownElevation) {
1820 double eleMax = -std::numeric_limits<double>::max();
1821 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[it];
1822 for (
const auto& primaryLayer : primaryLayers) {
1823 eleMax =
MAX2(eleMax, primaryLayer.first);
1825 knownEleMax[it] = eleMax;
1828 bool changed =
true;
1831 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1834 / gradeThreshold * 3,
1836 for (
auto& neighbor : neighbors) {
1837 if (knownElevation.count(neighbor.first) != 0) {
1838 const double grade = fabs(knownEleMax[*it] - knownEleMax[neighbor.first])
1839 /
MAX2(POSITION_EPS, neighbor.second.first);
1840 #ifdef DEBUG_LAYER_ELEVATION
1841 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";
1843 if (grade > gradeThreshold * 50 / 3.6 / neighbor.second.second) {
1845 const double eleMax =
MAX2(knownEleMax[*it], knownEleMax[neighbor.first]);
1846 if (knownEleMax[*it] < eleMax) {
1847 knownEleMax[*it] = eleMax;
1849 knownEleMax[neighbor.first] = eleMax;
1859 std::set<NBNode*> unknownElevation;
1860 for (
auto it = knownElevation.begin(); it != knownElevation.end(); ++it) {
1861 const double eleMax = knownEleMax[*it];
1862 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1863 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1864 for (
auto& neighbor : neighbors) {
1865 if (knownElevation.count(neighbor.first) == 0) {
1866 unknownElevation.insert(neighbor.first);
1867 layerForces[neighbor.first].emplace_back(eleMax, neighbor.second.first);
1873 for (
auto it = unknownElevation.begin(); it != unknownElevation.end(); ++it) {
1874 double eleMax = -std::numeric_limits<double>::max();
1875 const std::vector<std::pair<double, double> >& primaryLayers = layerForces[*it];
1876 for (
const auto& primaryLayer : primaryLayers) {
1877 eleMax =
MAX2(eleMax, primaryLayer.first);
1879 const double maxDist = fabs(eleMax) * 100 / layerElevation;
1880 std::map<NBNode*, std::pair<double, double> > neighbors =
getNeighboringNodes(*it, maxDist, knownElevation);
1881 for (
auto& neighbor : neighbors) {
1882 if (knownElevation.count(neighbor.first) == 0 && unknownElevation.count(neighbor.first) == 0) {
1883 layerForces[*it].emplace_back(0, neighbor.second.first);
1888 #ifdef DEBUG_LAYER_ELEVATION
1889 std::cout <<
"summation of forces\n";
1891 std::map<NBNode*, double> nodeElevation;
1892 for (
auto& layerForce : layerForces) {
1893 const std::vector<std::pair<double, double> >& forces = layerForce.second;
1894 if (knownElevation.count(layerForce.first) != 0) {
1902 #ifdef DEBUG_LAYER_ELEVATION
1903 std::cout <<
" node=" << it->first->getID() <<
" knownElevation=" << knownEleMax[it->first] <<
"\n";
1905 nodeElevation[layerForce.first] = knownEleMax[layerForce.first];
1906 }
else if (forces.size() == 1) {
1907 nodeElevation[layerForce.first] = forces.front().first;
1911 for (
const auto& force : forces) {
1912 distSum += force.second;
1914 double weightSum = 0;
1915 double elevation = 0;
1916 #ifdef DEBUG_LAYER_ELEVATION
1917 std::cout <<
" node=" << it->first->getID() <<
" distSum=" << distSum <<
"\n";
1919 for (
const auto& force : forces) {
1920 const double weight = (distSum - force.second) / distSum;
1921 weightSum += weight;
1922 elevation += force.first * weight;
1924 #ifdef DEBUG_LAYER_ELEVATION
1925 std::cout <<
" force=" << it_force->first <<
" dist=" << it_force->second <<
" weight=" << weight <<
" ele=" << elevation <<
"\n";
1928 nodeElevation[layerForce.first] = elevation / weightSum;
1931 #ifdef DEBUG_LAYER_ELEVATION
1932 std::cout <<
"final elevations:\n";
1933 for (std::map<NBNode*, double>::iterator it = nodeElevation.begin(); it != nodeElevation.end(); ++it) {
1934 std::cout <<
" node=" << (it->first)->getID() <<
" ele=" << it->second <<
"\n";
1938 for (
auto& it : nodeElevation) {
1945 for (
const auto& it : ec) {
1946 NBEdge* edge = it.second;
1948 const double length = geom.
length2D();
1949 const double zFrom = nodeElevation[edge->
getFromNode()];
1950 const double zTo = nodeElevation[edge->
getToNode()];
1955 for (
auto it_pos = geom.begin(); it_pos != geom.end(); ++it_pos) {
1956 if (it_pos != geom.begin()) {
1957 dist += (*it_pos).distanceTo2D(*(it_pos - 1));
1959 newGeom.push_back((*it_pos) +
Position(0, 0, zFrom + (zTo - zFrom) * dist / length));
1965 std::map<NBNode*, std::pair<double, double> >
1967 std::map<NBNode*, std::pair<double, double> > result;
1968 std::set<NBNode*> visited;
1969 std::vector<NBNode*> open;
1970 open.push_back(node);
1971 result[node] = std::make_pair(0, 0);
1972 while (!open.empty()) {
1975 if (visited.count(n) != 0) {
1980 for (
auto e : edges) {
1983 s = e->getFromNode();
1987 const double dist = result[n].first + e->getGeometry().length2D();
1988 const double speed =
MAX2(e->getSpeed(), result[n].second);
1989 if (result.count(s) == 0) {
1990 result[s] = std::make_pair(dist, speed);
1992 result[s] = std::make_pair(
MIN2(dist, result[s].first),
MAX2(speed, result[s].second));
1994 if (dist < maxDist && knownElevation.count(s) == 0) {
2006 if (tc.
knows(type)) {
2017 std::vector<std::string> types;
2019 std::string t = tok.
next();
2021 if (std::find(types.begin(), types.end(), t) == types.end()) {
2024 }
else if (tok.
size() > 1) {
2025 WRITE_WARNINGF(
"Discarding unknown compound '%' in type '%' (first occurence for edge '%').", t, type,
id);
2028 if (types.empty()) {
2029 WRITE_WARNINGF(
"Discarding unusable type '%' (first occurence for edge '%').", type,
id);
2034 if (tc.
knows(newType)) {
2042 double maxSpeed = 0;
2047 bool defaultIsOneWay =
true;
2050 bool discard =
true;
2051 for (
auto& type2 : types) {
2078 WRITE_WARNINGF(
"Discarding compound type '%' (first occurence for edge '%').", newType,
id);
2083 WRITE_MESSAGE(
"Adding new type '" + type +
"' (first occurence for edge '" +
id +
"').");
2084 tc.
insertEdgeType(newType, numLanes, maxSpeed, prio, permissions, spreadType, width,
2085 defaultIsOneWay, sidewalkWidth, bikelaneWidth, 0, 0, 0);
2086 for (
auto& type3 : types) {
2101 std::vector<NIOSMNode*> nodes;
2102 std::vector<double> usablePositions;
2103 std::vector<int> usableIndex;
2107 if (node->
positionMeters != std::numeric_limits<double>::max()) {
2109 usableIndex.push_back((
int)nodes.size());
2111 nodes.push_back(node);
2113 if (usablePositions.size() == 0) {
2116 bool forward =
true;
2117 if (usablePositions.size() == 1) {
2118 WRITE_WARNINGF(
"Ambiguous railway kilometrage direction for way '%' (assuming forward)",
id);
2120 forward = usablePositions.front() < usablePositions.back();
2123 for (
int i = 1; i < (int)usablePositions.size(); i++) {
2124 if ((usablePositions[i - 1] < usablePositions[i]) != forward) {
2125 WRITE_WARNINGF(
"Inconsistent railway kilometrage direction for way '%': %s (skipping)",
id,
toString(usablePositions));
2129 if (nodes.size() > usablePositions.size()) {
2133 shape.push_back(
Position(node->lon, node->lat, 0));
2138 double sign = forward ? 1 : -1;
2140 for (
int i = usableIndex.front() - 1; i >= 0; i--) {
2141 nodes[i]->positionMeters = nodes[i + 1]->positionMeters - sign * shape[i].distanceTo2D(shape[i + 1]);
2144 for (
int i = usableIndex.front() + 1; i < (
int)nodes.size(); i++) {
2145 if (nodes[i]->positionMeters == std::numeric_limits<double>::max()) {
2146 nodes[i]->positionMeters = nodes[i - 1]->positionMeters + sign * shape[i].distanceTo2D(shape[i - 1]);
2173 return std::numeric_limits<double>::max();
2179 if (type ==
"train") {
2181 }
else if (type ==
"subway" || type ==
"light_rail") {
2183 }
else if (type ==
"share_taxi") {
2185 }
else if (type ==
"minibus") {
2190 std::string stop =
"";
2193 }
else if (result ==
SVC_BUS) {
2207 bool multiLane = changeProhibition > 3;
2209 for (
int lane = 0; changeProhibition > 0 && lane < e->
getNumLanes(); lane++) {
2210 int code = changeProhibition % 4;
2215 changeProhibition = changeProhibition >> 2;
2225 for (
int lane = 0; lane < (int)laneUse.size(); lane++) {
2227 const int i = lefthand ? lane : e->
getNumLanes() - 1 - lane;
2229 if (laneUse[i] == 0) {
2249 for (
int i = 0; i < (int)turnSigns.size(); i++) {
2251 const int laneIndex = lefthand ? i : e->
getNumLanes() - 1 - i;
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#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.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
bool isBikepath(SVCPermissions permissions)
Returns whether an edge with the given permission is a bicycle edge.
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.
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
void setTurnSignTarget(const std::string &target)
void setDistance(double distance)
set lane specific speed (negative lane implies set for all lanes)
const std::string & getID() const
NBNode * getToNode() const
Returns the destination node of the edge.
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
int getNumLanes() const
Returns the number of lanes.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
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 double UNSPECIFIED_WIDTH
unspecified lane width
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Lane & getLaneStruct(int lane)
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
NBNode * getFromNode() const
Returns the origin node of the edge.
Instance responsible for building networks.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBParkingCont & getParkingCont()
NBPTLineCont & getPTLineCont()
Returns a reference to the pt line container.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
NBEdgeCont & getEdgeCont()
NBPTStopCont & getPTStopCont()
Returns a reference to the pt stop container.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
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 & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
const Position & getPosition() const
A traffic light logics which must be computed (only nodes/edges are given)
void addPTStop(NBPTStop *pStop)
const std::string & getLineID() const
void addWayNode(long long int way, long long int node)
void setMyNumOfStops(int numStops)
std::vector< NBPTStop * > getStops()
bool insert(NBPTStop *ptStop)
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.
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.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
void updateParameters(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value 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.
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 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 to_lower_case(std::string str)
Transfers the content to lower case.
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 bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
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.