@@ -330,7 +330,6 @@ namespace dsm {
330330 std::getline (iss, lon, ' ;' );
331331 std::getline (iss, lat, ' ;' );
332332 std::getline (iss, highway, ' ;' );
333- auto const nodeId{static_cast <Id>(std::stoul (id))};
334333 if (highway.find (" traffic_signals" ) != std::string::npos) {
335334 addNode<TrafficLight>(
336335 nodeIndex, 60 , std::make_pair (std::stod (lat), std::stod (lon)));
@@ -340,7 +339,7 @@ namespace dsm {
340339 addNode<Intersection>(nodeIndex,
341340 std::make_pair (std::stod (lat), std::stod (lon)));
342341 }
343- m_nodeMapping.emplace (std::make_pair (nodeId , nodeIndex));
342+ m_nodeMapping.emplace (std::make_pair (id , nodeIndex));
344343 ++nodeIndex;
345344 }
346345 } else {
@@ -394,7 +393,7 @@ namespace dsm {
394393 lanes = " 1" ; // Default to 1 lane if lanes is invalid
395394 }
396395 }
397- if (!m_nodeMapping.contains (std::stoul ( sourceId) )) {
396+ if (!m_nodeMapping.contains (sourceId)) {
398397 std::cerr << std::format (
399398 " \033 [38;5;196mERROR ({}:{}): Node with id {} not "
400399 " found.\033 [0m" ,
@@ -404,7 +403,7 @@ namespace dsm {
404403 << std::endl;
405404 std::abort ();
406405 }
407- if (!m_nodeMapping.contains (std::stoul ( targetId) )) {
406+ if (!m_nodeMapping.contains (targetId)) {
408407 std::cerr << std::format (
409408 " \033 [38;5;196mERROR ({}:{}): Node with id {} not "
410409 " found.\033 [0m" ,
@@ -414,8 +413,15 @@ namespace dsm {
414413 << std::endl;
415414 std::abort ();
416415 }
417- auto const srcId{m_nodeMapping.at (std::stoul (sourceId))};
418- auto const dstId{m_nodeMapping.at (std::stoul (targetId))};
416+ auto const srcId{m_nodeMapping.at (sourceId)};
417+ auto const dstId{m_nodeMapping.at (targetId)};
418+ if (static_cast <unsigned long long >(srcId * nNodes + dstId) >
419+ std::numeric_limits<Id>::max ()) {
420+ throw std::invalid_argument (buildLog (
421+ std::format (" Street id {}->{} would too large for the current type of Id." ,
422+ srcId,
423+ dstId)));
424+ }
419425 Id streetId = srcId * nNodes + dstId;
420426 addEdge<Street>(streetId,
421427 std::make_pair (srcId, dstId),
0 commit comments