Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-12-22 13:57:16 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:03:16 +0300
commit2fe8fee598e31e2a456b09208b2d53eeb69df0c9 (patch)
tree6354377d1817bbab9e8374238c87996e95574c3d /indexer/feature_algo.cpp
parent21370ee3d9635139c460addabdf60abb559369c7 (diff)
[search] Get street name and house number from point.
Diffstat (limited to 'indexer/feature_algo.cpp')
-rw-r--r--indexer/feature_algo.cpp54
1 files changed, 49 insertions, 5 deletions
diff --git a/indexer/feature_algo.cpp b/indexer/feature_algo.cpp
index ee13427d6f..fe501c03a6 100644
--- a/indexer/feature_algo.cpp
+++ b/indexer/feature_algo.cpp
@@ -101,13 +101,13 @@ public:
m2::PointD GetCenter(FeatureType const & f, int scale)
{
- feature::EGeomType const type = f.GetFeatureType();
+ EGeomType const type = f.GetFeatureType();
switch (type)
{
- case feature::GEOM_POINT:
+ case GEOM_POINT:
return f.GetCenter();
- case feature::GEOM_LINE:
+ case GEOM_LINE:
{
CalculateLineCenter doCalc;
f.ForEachPointRef(doCalc, scale);
@@ -116,7 +116,7 @@ m2::PointD GetCenter(FeatureType const & f, int scale)
default:
{
- ASSERT_EQUAL ( type, feature::GEOM_AREA, () );
+ ASSERT_EQUAL(type, GEOM_AREA, ());
CalculatePointOnSurface doCalc(f.GetLimitRect(scale));
f.ForEachTriangleRef(doCalc, scale);
return doCalc.GetCenter();
@@ -124,6 +124,50 @@ m2::PointD GetCenter(FeatureType const & f, int scale)
}
}
-m2::PointD GetCenter(FeatureType const & f) { return GetCenter(f, FeatureType::BEST_GEOMETRY); }
+m2::PointD GetCenter(FeatureType const & f)
+{
+ return GetCenter(f, FeatureType::BEST_GEOMETRY);
+}
+
+double GetMinDistance(FeatureType const & ft, m2::PointD const & pt, int scale)
+{
+ double res = numeric_limits<double>::max();
+ auto distanceFn = [&] (m2::PointD const & p)
+ {
+ double const d = MercatorBounds::DistanceOnEarth(p, pt);
+ if (d < res)
+ res = d;
+ };
+
+ /// @todo Need to check projection here?
+ EGeomType const type = ft.GetFeatureType();
+ switch (type)
+ {
+ case GEOM_POINT:
+ distanceFn(ft.GetCenter());
+ break;
+
+ case GEOM_LINE:
+ ft.ForEachPoint(distanceFn, scale);
+ break;
+
+ default:
+ ASSERT_EQUAL(type, GEOM_AREA, ());
+ ft.ForEachTriangle([&] (m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3)
+ {
+ distanceFn(p1);
+ distanceFn(p2);
+ distanceFn(p3);
+ }, scale);
+ break;
+ }
+
+ return res;
+}
+
+double GetMinDistance(FeatureType const & ft, m2::PointD const & pt)
+{
+ return GetMinDistance(ft, pt, FeatureType::BEST_GEOMETRY);
+}
}