MCPcopy Create free account
hub / github.com/comaps/comaps / ParseMaxspeeds

Function ParseMaxspeeds

generator/maxspeeds_builder.cpp:503–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501};
502
503bool ParseMaxspeeds(string const & filePath, OsmIdToMaxspeed & osmIdToMaxspeed)
504{
505 osmIdToMaxspeed.clear();
506
507 std::ifstream stream(filePath);
508 if (!stream)
509 return false;
510
511 string line;
512 while (stream.good())
513 {
514 getline(stream, line);
515 strings::SimpleTokenizer iter(line, kDelim);
516
517 if (!iter) // empty line
518 continue;
519
520 uint64_t osmId = 0;
521 if (!strings::to_uint(*iter, osmId))
522 return false;
523 ++iter;
524
525 if (!iter)
526 return false;
527 Maxspeed speed;
528 speed.SetUnits(StringToUnits(*iter));
529 ++iter;
530
531 MaxspeedType forward = 0;
532 if (!ParseOneSpeedValue(iter, forward))
533 return false;
534
535 speed.SetForward(forward);
536
537 if (iter)
538 {
539 // There's backward maxspeed limit.
540 MaxspeedType backward = 0;
541 if (!ParseOneSpeedValue(iter, backward))
542 return false;
543
544 speed.SetBackward(backward);
545
546 if (iter)
547 return false;
548 }
549
550 auto const res = osmIdToMaxspeed.emplace(base::MakeOsmWay(osmId), speed);
551 if (!res.second)
552 return false;
553 }
554 return true;
555}
556
557void BuildMaxspeedsSection(IndexGraph * graph, string const & dataPath, FeatureIdToOsmId const & featureIdToOsmId,
558 string const & maxspeedsFilename)

Callers 4

ProcessMethod · 0.85
TestMaxspeedsSectionFunction · 0.85
ParseCsvFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 9

to_uintFunction · 0.85
StringToUnitsFunction · 0.85
ParseOneSpeedValueFunction · 0.85
MakeOsmWayFunction · 0.85
SetForwardMethod · 0.80
SetBackwardMethod · 0.80
clearMethod · 0.45
SetUnitsMethod · 0.45
emplaceMethod · 0.45

Tested by 3

TestMaxspeedsSectionFunction · 0.68
ParseCsvFunction · 0.68
UNIT_TESTFunction · 0.68