blob: 148dd289a961ec644810ce0a6901912b9325017a (
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
|
#include "geometry_utils.hpp"
#include "../indexer/mercator.hpp"
#include "../geometry/distance_on_sphere.hpp"
namespace search
{
double PointDistance(m2::PointD const & a, m2::PointD const & b)
{
return ms::DistanceOnEarth(MercatorBounds::YToLat(a.y), MercatorBounds::XToLon(a.x),
MercatorBounds::YToLat(b.y), MercatorBounds::XToLon(b.x));
}
uint8_t ViewportDistance(m2::RectD const & viewport, m2::PointD const & p)
{
if (viewport.IsPointInside(p))
return 0;
m2::RectD r = viewport;
r.Scale(3);
if (r.IsPointInside(p))
return 1;
r = viewport;
r.Scale(5);
if (r.IsPointInside(p))
return 2;
return 3;
}
}
|