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

Function WriteCitiesIdsSectionToFile

generator/cities_ids_builder.cpp:39–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void WriteCitiesIdsSectionToFile(std::string const & dataPath,
40 ankerl::unordered_dense::map<uint32_t, base::GeoObjectId> const & mapping)
41{
42 indexer::FeatureIdToGeoObjectIdBimapMem map;
43 auto const localities = generator::GetLocalities(dataPath);
44 localities.ForEach([&](uint64_t fid64)
45 {
46 auto const fid = base::checked_cast<uint32_t>(fid64);
47 auto const it = mapping.find(fid);
48 if (it == mapping.end())
49 return;
50
51 auto const osmId = it->second;
52 if (!map.Add(fid, osmId))
53 {
54 uint32_t oldFid;
55 base::GeoObjectId oldOsmId;
56 auto const hasOldOsmId = map.GetValue(fid, oldOsmId);
57 auto const hasOldFid = map.GetKey(osmId, oldFid);
58
59 LOG(LWARNING, ("Could not add the pair (", fid, ",", osmId,
60 ") to the cities ids section; old fid:", (hasOldFid ? DebugPrint(oldFid) : "none"),
61 "old osmId:", (hasOldOsmId ? DebugPrint(oldOsmId) : "none")));
62 }
63 });
64
65 FilesContainerW container(dataPath, FileWriter::OP_WRITE_EXISTING);
66 // Note that we only store cities ids but nothing stops us from
67 // generalizing the section if we need, so a more generic tag is used.
68 auto sink = container.GetWriter(FEATURE_TO_OSM_FILE_TAG);
69 auto const pos0 = sink->Pos();
70 indexer::FeatureIdToGeoObjectIdSerDes::Serialize(*sink, map);
71 auto const pos1 = sink->Pos();
72
73 LOG(LINFO, ("Serialized cities ids. Number of entries:", map.Size(), "Size in bytes:", pos1 - pos0));
74}
75} // namespace
76
77namespace generator

Callers 2

BuildCitiesIdsFunction · 0.85
BuildCitiesIdsForTestingFunction · 0.85

Calls 12

GetLocalitiesFunction · 0.85
SerializeFunction · 0.85
GetWriterMethod · 0.80
DebugPrintFunction · 0.70
ForEachMethod · 0.45
findMethod · 0.45
endMethod · 0.45
AddMethod · 0.45
GetValueMethod · 0.45
GetKeyMethod · 0.45
PosMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected