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

Method WikidataHelper

generator/descriptions_section_builder.cpp:32–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30} // namespace
31
32WikidataHelper::WikidataHelper(std::string const & mwmPath, std::string const & idToWikidataPath)
33{
34 if (idToWikidataPath.empty())
35 return;
36
37 std::string const osmIdsToFeatureIdsPath = mwmPath + OSM2FEATURE_FILE_EXTENSION;
38 if (!ParseFeatureIdToOsmIdMapping(osmIdsToFeatureIdsPath, m_featureIdToOsmId))
39 LOG(LCRITICAL, ("Mapping parse error for file ", osmIdsToFeatureIdsPath));
40
41 std::ifstream stream(idToWikidataPath);
42 if (!stream)
43 LOG(LERROR, ("File ", idToWikidataPath, " not found. Consider skipping Descriptions stage."));
44 stream.exceptions(std::fstream::badbit);
45
46 uint64_t id;
47 std::string wikidataId;
48 while (stream)
49 {
50 stream >> id >> wikidataId;
51 strings::Trim(wikidataId);
52 m_osmIdToWikidataId.emplace(base::GeoObjectId(id), wikidataId);
53 }
54}
55
56std::optional<std::string> WikidataHelper::GetWikidataId(uint32_t featureId) const
57{

Callers

nothing calls this directly

Calls 5

TrimFunction · 0.85
GeoObjectIdClass · 0.70
emptyMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected