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

Method Save

generator/road_access_generator.cpp:424–475  ·  view source on GitHub ↗

@see correspondent ReadRoadAccess.

Source from the content-addressed store, hash-verified

422
423/// @see correspondent ReadRoadAccess.
424void RoadAccessCollector::Save()
425{
426 auto fileName = GetFilename();
427
428 LOG(LINFO, ("Saving road access values to", fileName));
429 FileWriter writer(fileName);
430
431 for (auto & p : m_tagProcessors)
432 {
433 p.m_wayToAccess.Serialize(writer);
434 p.m_wayToAccessConditional.Serialize(writer);
435 }
436
437 generator::SizeWriter<uint64_t> sizeWriter;
438 uint64_t count = 0;
439 sizeWriter.Reserve(writer);
440
441 m_roads.ForEachWayWithIndex([&](uint64_t wayID, std::vector<uint64_t> const & nodes, size_t idx)
442 {
443 for (auto & p : m_tagProcessors)
444 {
445 for (uint32_t nodeIdx = 0; nodeIdx < nodes.size(); ++nodeIdx)
446 {
447 uint64_t const nodeID = nodes[nodeIdx];
448 auto const * entry = p.m_barriersWithAccessTag.Find(nodeID);
449 if (entry == nullptr)
450 {
451 entry = p.m_barriersWithoutAccessTag.Find(nodeID);
452 if (entry == nullptr)
453 continue;
454
455 if (p.IsIgnoreBarriers(idx))
456 {
457 // Dump only bicycle profile with the most wide barriers set to ignore.
458 if (p.m_vehicleType == VehicleType::Bicycle)
459 LOG(LDEBUG, ("Node barrier without access:", nodeID));
460 continue;
461 }
462 }
463
464 ++count;
465 // Write vehicle type for each entry to avoid multiple roads iterating.
466 WriteToSink(writer, static_cast<uint8_t>(p.m_vehicleType));
467 entry->Write(writer, wayID, nodeIdx);
468 }
469 }
470 }, m_cache);
471
472 sizeWriter.Write(writer, count);
473
474 LOG(LINFO, ("Finished saving road access values"));
475}
476
477void RoadAccessCollector::MergeInto(RoadAccessCollector & collector) const
478{

Callers

nothing calls this directly

Calls 8

WriteToSinkFunction · 0.85
ForEachWayWithIndexMethod · 0.80
IsIgnoreBarriersMethod · 0.80
SerializeMethod · 0.45
ReserveMethod · 0.45
sizeMethod · 0.45
FindMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected