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-23 19:33:05 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:03:17 +0300
commitf6ac3786d755afde9534b28e9a1977e38b3aa470 (patch)
tree239acb986e517ef84c31d4991a37df7f6d3bc4c1 /indexer/feature.cpp
parent8c57791e1d87fa500b3f7bb1b13f45282edc0cf1 (diff)
Refactored some geometry functions.
Correct implementation of feature::GetMinDistanceMeters().
Diffstat (limited to 'indexer/feature.cpp')
-rw-r--r--indexer/feature.cpp76
1 files changed, 0 insertions, 76 deletions
diff --git a/indexer/feature.cpp b/indexer/feature.cpp
index 1459eb9c56..08ff227205 100644
--- a/indexer/feature.cpp
+++ b/indexer/feature.cpp
@@ -352,82 +352,6 @@ bool FeatureType::HasInternet() const
return res;
}
-namespace
-{
- class DoCalcDistance
- {
- m2::PointD m_prev, m_pt;
- bool m_hasPrev;
-
- static double Inf() { return numeric_limits<double>::max(); }
-
- static double GetDistance(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p)
- {
- m2::DistanceToLineSquare<m2::PointD> calc;
- calc.SetBounds(p1, p2);
- return sqrt(calc(p));
- }
-
- public:
- DoCalcDistance(m2::PointD const & pt)
- : m_pt(pt), m_hasPrev(false), m_dist(Inf())
- {
- }
-
- void TestPoint(m2::PointD const & p)
- {
- m_dist = m_pt.Length(p);
- }
-
- void operator() (m2::PointD const & pt)
- {
- if (m_hasPrev)
- m_dist = min(m_dist, GetDistance(m_prev, pt, m_pt));
- else
- m_hasPrev = true;
-
- m_prev = pt;
- }
-
- void operator() (m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3)
- {
- m2::PointD arrP[] = { p1, p2, p3 };
-
- // make right-oriented triangle
- if (m2::robust::OrientedS(arrP[0], arrP[1], arrP[2]) < 0.0)
- swap(arrP[1], arrP[2]);
-
- double d = Inf();
- for (size_t i = 0; i < 3; ++i)
- {
- double const s = m2::robust::OrientedS(arrP[i], arrP[(i + 1) % 3], m_pt);
- if (s < 0.0)
- d = min(d, GetDistance(arrP[i], arrP[(i + 1) % 3], m_pt));
- }
-
- m_dist = ((d == Inf()) ? 0.0 : min(m_dist, d));
- }
-
- double m_dist;
- };
-}
-
-double FeatureType::GetDistance(m2::PointD const & pt, int scale) const
-{
- DoCalcDistance calc(pt);
-
- switch (GetFeatureType())
- {
- case GEOM_POINT: calc.TestPoint(GetCenter()); break;
- case GEOM_LINE: ForEachPointRef(calc, scale); break;
- case GEOM_AREA: ForEachTriangleRef(calc, scale); break;
- default:
- CHECK ( false, () );
- }
-
- return calc.m_dist;
-}
-
void FeatureType::SwapGeometry(FeatureType & r)
{
ASSERT_EQUAL(m_bPointsParsed, r.m_bPointsParsed, ());