From 87f4f3aca9457d144174619888da06001eb9c8fc Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 26 Sep 2011 22:42:50 +0300 Subject: [PATCH] Make special simplification only for levels that >= scales::GetUpperWorldScale(). --- generator/feature_generator.cpp | 3 +- generator/feature_generator.hpp | 2 -- generator/feature_sorter.cpp | 51 ++++----------------------------- generator/feature_sorter.hpp | 4 +-- geometry/distance.hpp | 2 -- 5 files changed, 8 insertions(+), 54 deletions(-) diff --git a/generator/feature_generator.cpp b/generator/feature_generator.cpp index a941cbfd45..af4b1379d5 100644 --- a/generator/feature_generator.cpp +++ b/generator/feature_generator.cpp @@ -271,7 +271,8 @@ public: if (info.m_createWorld) { m_world.reset(new WorldMapGenerator(info)); - m_coasts.reset(new CoastlineFeaturesGenerator(m_coastType, g_coastsCellLevel)); + // 6 - is cell level for oceans covering + m_coasts.reset(new CoastlineFeaturesGenerator(m_coastType, 6)); m_coastsHolder.reset(new FeaturesCollector( info.m_datFilePrefix + WORLD_COASTS_FILE_NAME + info.m_datFileSuffix)); } diff --git a/generator/feature_generator.hpp b/generator/feature_generator.hpp index cf0f052c13..40f94f1a64 100644 --- a/generator/feature_generator.hpp +++ b/generator/feature_generator.hpp @@ -34,6 +34,4 @@ namespace feature void operator() (FeatureBuilder1 const & f); }; - - static const int g_coastsCellLevel = 7; } diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index 29c49818d7..1714b5cb69 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -353,51 +353,16 @@ namespace feature } }; - /* - class less_points - { - double const m_eps; - public: - less_points() : m_eps(1.0E-6) {} - - bool operator() (m2::PointD const & p1, m2::PointD const & p2) const - { - if (p1.x + m_eps < p2.x) return true; - if (fabs(p1.x - p2.x) <= m_eps) - return (p1.y + m_eps < p2.y); - else return false; - } - }; - - class equal_points - { - double const m_eps; - public: - equal_points() : m_eps(1.0E-6) {} - - bool operator() (m2::PointD const & p1, m2::PointD const & p2) const - { - return p1.EqualDxDy(p2, m_eps); - } - }; - - typedef set points_set_t; - */ - class BoundsDistance : public mn::DistanceToLineSquare { double m_eps; double m_minX, m_minY, m_maxX, m_maxY; public: - BoundsDistance(uint32_t cellID, int level) + BoundsDistance() : m_eps(MercatorBounds::GetCellID2PointAbsEpsilon()) { - RectId const cell = RectId::FromBitsAndLevel(cellID, level); - CellIdConverter::GetCellBounds(cell, m_minX, m_minY, m_maxX, m_maxY); } - void SetEpsilon(double eps) { m_eps = eps; } - double operator() (m2::PointD const & p) const { if (fabs(p.x - m_minX) <= m_eps || fabs(p.x - m_maxX) <= m_eps || @@ -415,18 +380,12 @@ namespace feature FeatureBuilder2 const & fb) { uint32_t cellID; - if (fb.GetCoastCell(cellID)) + if ((level >= scales::GetUpperWorldScale()) && fb.GetCoastCell(cellID)) { - /* - points_set_t toSkip; - { - points_t v(in); - sort(v.begin(), v.end(), less_points()); - toSkip.insert(unique(v.begin(), v.end(), equal_points()), v.end()); - } - */ + // Note! Do such special simplification only for upper world level and countries levels. + // There is no need for this simplification in small world levels. - BoundsDistance dist(cellID, g_coastsCellLevel); + BoundsDistance dist; feature::SimplifyPoints(dist, in, out, level); } else diff --git a/generator/feature_sorter.hpp b/generator/feature_sorter.hpp index 279e1aedde..046552a321 100644 --- a/generator/feature_sorter.hpp +++ b/generator/feature_sorter.hpp @@ -30,10 +30,8 @@ namespace feature { if (in.size() >= 2) { - double eps = scales::GetEpsilonForSimplify(level); - dist.SetEpsilon(eps); + double const eps = my::sq(scales::GetEpsilonForSimplify(level)); - eps = my::sq(eps); SimplifyNearOptimal(20, in.begin(), in.end(), eps, dist, AccumulateSkipSmallTrg(dist, out, eps)); diff --git a/geometry/distance.hpp b/geometry/distance.hpp index b4097851c3..45efe20b97 100644 --- a/geometry/distance.hpp +++ b/geometry/distance.hpp @@ -17,8 +17,6 @@ private: STATIC_ASSERT(numeric_limits::is_signed); public: - void SetEpsilon(double) {} - void SetBounds(PointT const & p0, PointT const & p1) { m_P0 = p0;