blob: 96686393066765442fa6b8d1ebd4d441a47b43c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#pragma once
#include "search/reverse_geocoder.hpp"
// TODO: get rid of this class when version 8.6 will not be supported.
// TODO: because of fast algorithm and new mwm section which were implemented for 9.0.
// Note: this class is NOT thread-safe.
class CachingAddressGetter
{
public:
search::ReverseGeocoder::Address GetAddressAtPoint(DataSource const & dataSource,
m2::PointD const & pt) const
{
if (pt.EqualDxDy(m_cache.m_point, kMwmPointAccuracy))
return m_cache.m_address;
double const kDistanceThresholdMeters = 0.5;
m_cache.m_point = pt;
m_cache.m_address = {};
search::ReverseGeocoder const coder(dataSource);
coder.GetNearbyAddress(pt, kDistanceThresholdMeters, m_cache.m_address);
return m_cache.m_address;
}
private:
struct Cache
{
m2::PointD m_point;
search::ReverseGeocoder::Address m_address;
};
mutable Cache m_cache;
};
|