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

Method PostcodePoints

libs/search/postcode_points.cpp:38–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38PostcodePoints::PostcodePoints(MwmValue const & value)
39{
40 auto reader = value.m_cont.GetReader(POSTCODE_POINTS_FILE_TAG);
41 m_header.Read(*reader.GetPtr());
42
43 m_trieSubReader = reader.GetPtr()->CreateSubReader(m_header.m_trieOffset, m_header.m_trieSize);
44 m_root = trie::ReadTrie<SubReaderWrapper<Reader>, SingleUint64Value>(SubReaderWrapper<Reader>(m_trieSubReader.get()),
45 SingleValueSerializer<Uint64IndexValue>());
46 CHECK(m_root, ());
47
48 version::MwmTraits traits(value.GetMwmVersion());
49 auto const format = traits.GetCentersTableFormat();
50 CHECK_EQUAL(format, version::MwmTraits::CentersTableFormat::EliasFanoMapWithHeader, ("Unexpected format."));
51
52 m_pointsSubReader = reader.GetPtr()->CreateSubReader(m_header.m_pointsOffset, m_header.m_pointsSize);
53 m_points = CentersTable::LoadV1(*m_pointsSubReader);
54 CHECK(m_points, ());
55
56 auto constexpr kPostcodeRadiusMultiplier = 5.0;
57 auto const area = value.GetHeader().GetBounds().Area();
58 auto const count = static_cast<double>(m_points->Count());
59 CHECK_NOT_EQUAL(count, 0.0, ("Zero postcodes should not be serialized to", POSTCODE_POINTS_FILE_TAG, "section"));
60 m_radius = kPostcodeRadiusMultiplier * 0.5 * sqrt(area / count);
61}
62
63void PostcodePoints::Get(UniString const & postcode, bool recursive, vector<m2::PointD> & points) const
64{

Callers

nothing calls this directly

Calls 11

GetMwmVersionMethod · 0.80
GetCentersTableFormatMethod · 0.80
GetHeaderMethod · 0.80
getMethod · 0.65
GetReaderMethod · 0.45
ReadMethod · 0.45
GetPtrMethod · 0.45
CreateSubReaderMethod · 0.45
AreaMethod · 0.45
GetBoundsMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected