blob: a6ba2354103b3a490dd5b4bf7d220dc94b9c79c1 (
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
35
36
37
38
39
40
41
42
|
#include "geometry_utils.hpp"
#include "indexer/mercator.hpp"
#include "indexer/scales.hpp"
namespace search
{
double PointDistance(m2::PointD const & a, m2::PointD const & b)
{
return MercatorBounds::DistanceOnEarth(a, b);
}
bool IsEqualMercator(m2::RectD const & r1, m2::RectD const & r2, double epsMeters)
{
double const eps = epsMeters * MercatorBounds::degreeInMetres;
return m2::IsEqual(r1, r2, eps, eps);
}
// 11.5 - lower bound for rect when we need to inflate it
// 1.5 - inflate delta for viewport scale
// 7 - query scale depth to cache viewport features
bool GetInflatedViewport(m2::RectD & viewport)
{
double level = scales::GetScaleLevelD(viewport);
if (level < 11.5)
return false;
if (level > 16.5)
level = 16.5;
viewport = scales::GetRectForLevel(level - 1.5, viewport.Center());
return true;
}
int GetQueryIndexScale(m2::RectD const & viewport)
{
return scales::GetScaleLevel(viewport) + 7;
}
} // namespace search
|