diff options
author | Anatoly Serdtcev <serdtcev@maps.me> | 2019-04-01 15:37:05 +0300 |
---|---|---|
committer | Maksim Andrianov <maksimandrianov1@gmail.com> | 2019-06-04 18:52:40 +0300 |
commit | c0d546985535cf89dcd4dcfef2c9c5253eb9ced5 (patch) | |
tree | 72349a129bef0e5766f6767132715454f3787152 /generator | |
parent | f416a7940b7ee39242fe074cd4033274f6deeaeb (diff) |
[generator] Fix regions index generation: ignore features types
Diffstat (limited to 'generator')
-rw-r--r-- | generator/feature_helpers.cpp | 12 | ||||
-rw-r--r-- | generator/feature_helpers.hpp | 8 | ||||
-rw-r--r-- | generator/locality_sorter.cpp | 17 |
3 files changed, 28 insertions, 9 deletions
diff --git a/generator/feature_helpers.cpp b/generator/feature_helpers.cpp index 6fdf57455b..5bfaa49bc6 100644 --- a/generator/feature_helpers.cpp +++ b/generator/feature_helpers.cpp @@ -2,8 +2,6 @@ #include "generator/feature_builder.hpp" -#include "indexer/feature_visibility.hpp" - #include "coding/point_coding.hpp" #include "base/stl_helpers.hpp" @@ -14,6 +12,14 @@ using namespace std; namespace feature { +CalculateMidPoints::CalculateMidPoints() + : CalculateMidPoints(static_cast<int (*)(TypesHolder const & types, m2::RectD limitRect)>(GetMinDrawableScale)) +{ } + +CalculateMidPoints::CalculateMidPoints(MinDrawableScalePolicy const & minDrawableScalePolicy) + : m_minDrawableScalePolicy{minDrawableScalePolicy} +{ } + void CalculateMidPoints::operator()(FeatureBuilder1 const & ft, uint64_t pos) { // Reset state. @@ -25,7 +31,7 @@ void CalculateMidPoints::operator()(FeatureBuilder1 const & ft, uint64_t pos) m_midLoc = m_midLoc / m_locCount; uint64_t const pointAsInt64 = PointToInt64Obsolete(m_midLoc, m_coordBits); - int const minScale = feature::GetMinDrawableScale(ft.GetTypesHolder(), ft.GetLimitRect()); + int const minScale = m_minDrawableScalePolicy(ft.GetTypesHolder(), ft.GetLimitRect()); /// May be invisible if it's small area object with [0-9] scales. /// @todo Probably, we need to keep that objects if 9 scale (as we do in 17 scale). diff --git a/generator/feature_helpers.hpp b/generator/feature_helpers.hpp index 34dfd69560..77dc260411 100644 --- a/generator/feature_helpers.hpp +++ b/generator/feature_helpers.hpp @@ -6,6 +6,8 @@ #include "geometry/point2d.hpp" #include "geometry/simplification.hpp" +#include "indexer/feature_data.hpp" +#include "indexer/feature_visibility.hpp" #include "indexer/scales.hpp" #include "base/assert.hpp" @@ -13,6 +15,7 @@ #include <cmath> #include <cstdint> +#include <functional> #include <limits> #include <utility> #include <vector> @@ -25,8 +28,10 @@ class CalculateMidPoints { public: using CellAndOffset = std::pair<uint64_t, uint64_t>; + using MinDrawableScalePolicy = std::function<int(TypesHolder const & types, m2::RectD limitRect)>; - CalculateMidPoints() = default; + CalculateMidPoints(); + CalculateMidPoints(MinDrawableScalePolicy const & minDrawableScalePolicy); void operator()(FeatureBuilder1 const & ft, uint64_t pos); bool operator()(m2::PointD const & p); @@ -42,6 +47,7 @@ private: size_t m_locCount = 0; size_t m_allCount = 0; uint8_t m_coordBits = serial::GeometryCodingParams().GetCoordBits(); + MinDrawableScalePolicy m_minDrawableScalePolicy; std::vector<CellAndOffset> m_vec; }; diff --git a/generator/locality_sorter.cpp b/generator/locality_sorter.cpp index 2c8ac3266a..f869b7ff32 100644 --- a/generator/locality_sorter.cpp +++ b/generator/locality_sorter.cpp @@ -193,7 +193,9 @@ bool ParseNodes(string nodesFile, set<uint64_t> & nodeIds) } using NeedSerialize = function<bool(FeatureBuilder1 & fb1)>; -bool GenerateLocalityDataImpl(FeaturesCollector & collector, NeedSerialize const & needSerialize, +bool GenerateLocalityDataImpl(FeaturesCollector & collector, + CalculateMidPoints::MinDrawableScalePolicy const & minDrawableScalePolicy, + NeedSerialize const & needSerialize, string const & featuresFile, string const & dataFile) { // Transform features from raw format to LocalityObject format. @@ -201,7 +203,7 @@ bool GenerateLocalityDataImpl(FeaturesCollector & collector, NeedSerialize const { LOG(LINFO, ("Processing", featuresFile)); - CalculateMidPoints midPoints; + CalculateMidPoints midPoints{minDrawableScalePolicy}; ForEachFromDatRawFormat(featuresFile, midPoints); // Sort features by their middle point. @@ -253,7 +255,10 @@ bool GenerateGeoObjectsData(string const & featuresFile, string const & nodesFil LocalityCollector localityCollector(dataFile, header, static_cast<uint32_t>(base::SecondsSinceEpoch())); - return GenerateLocalityDataImpl(localityCollector, needSerialize, featuresFile, dataFile); + return GenerateLocalityDataImpl( + localityCollector, + static_cast<int (*)(TypesHolder const & types, m2::RectD limitRect)>(GetMinDrawableScale), + needSerialize, featuresFile, dataFile); } bool GenerateRegionsData(string const & featuresFile, string const & dataFile) @@ -265,13 +270,15 @@ bool GenerateRegionsData(string const & featuresFile, string const & dataFile) LocalityCollector regionsCollector(dataFile, header, static_cast<uint32_t>(base::SecondsSinceEpoch())); auto const needSerialize = [](FeatureBuilder1 const & fb) { return fb.IsArea(); }; - return GenerateLocalityDataImpl(regionsCollector, needSerialize, featuresFile, dataFile); + return GenerateLocalityDataImpl(regionsCollector, GetMinDrawableScaleGeometryOnly, + needSerialize, featuresFile, dataFile); } bool GenerateBorders(string const & featuresFile, string const & dataFile) { BordersCollector bordersCollector(dataFile); auto const needSerialize = [](FeatureBuilder1 const & fb) { return fb.IsArea(); }; - return GenerateLocalityDataImpl(bordersCollector, needSerialize, featuresFile, dataFile); + return GenerateLocalityDataImpl(bordersCollector, GetMinDrawableScaleGeometryOnly, + needSerialize, featuresFile, dataFile); } } // namespace feature |