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>2014-01-08 14:44:31 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:09:48 +0300
commitcb62862b3460a4e1b5ccc7e31f1a6eaa2e185bdd (patch)
tree195338e3252888d8a63b310d7094c5ad687570bf
parent2182deb16077d6cb771e76d7e339bb268a6dc422 (diff)
[generator] Additional visibility checks for generating World and countries.
-rw-r--r--generator/feature_builder.cpp9
-rw-r--r--generator/feature_generator.cpp18
-rw-r--r--generator/feature_merger.cpp28
-rw-r--r--generator/feature_merger.hpp3
-rw-r--r--generator/feature_sorter.cpp12
-rw-r--r--generator/world_map_generator.hpp18
-rw-r--r--indexer/feature_data.cpp4
7 files changed, 67 insertions, 25 deletions
diff --git a/generator/feature_builder.cpp b/generator/feature_builder.cpp
index 782f8cbb67..1f5be0b099 100644
--- a/generator/feature_builder.cpp
+++ b/generator/feature_builder.cpp
@@ -385,15 +385,10 @@ string DebugPrint(FeatureBuilder1 const & f)
case GEOM_POINT: out << DebugPrint(f.m_Center); break;
case GEOM_LINE: out << "line with " << f.GetPointsCount() << " points"; break;
case GEOM_AREA: out << "area with " << f.GetPointsCount() << " points"; break;
- default:
- out << "ERROR: unknown geometry type"; break;
+ default: out << "ERROR: unknown geometry type"; break;
}
- return (out.str() + " " +
- DebugPrint(f.m_LimitRect) + " " +
- DebugPrint(f.m_Params) + " " +
- DebugPrint(f.m_Polygons)
- );
+ return (out.str() + " " + DebugPrint(f.m_LimitRect) + " " + DebugPrint(f.m_Params));
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/generator/feature_generator.cpp b/generator/feature_generator.cpp
index d40ebfe78f..08a158e3e2 100644
--- a/generator/feature_generator.cpp
+++ b/generator/feature_generator.cpp
@@ -257,8 +257,11 @@ public:
class MainFeaturesEmitter
{
- scoped_ptr<Polygonizer<FeaturesCollector> > m_countries;
- scoped_ptr<WorldMapGenerator<FeaturesCollector> > m_world;
+ typedef WorldMapGenerator<FeaturesCollector> WorldGenerator;
+ typedef CountryMapGenerator<Polygonizer<FeaturesCollector> > CountriesGenerator;
+ scoped_ptr<CountriesGenerator> m_countries;
+ scoped_ptr<WorldGenerator> m_world;
+
scoped_ptr<CoastlineFeaturesGenerator> m_coasts;
scoped_ptr<FeaturesCollector> m_coastsHolder;
@@ -313,7 +316,7 @@ public:
if (!info.m_makeCoasts)
{
- m_countries.reset(new Polygonizer<FeaturesCollector>(info));
+ m_countries.reset(new CountriesGenerator(info));
if (info.m_emitCoasts)
{
@@ -332,7 +335,7 @@ public:
if (info.m_createWorld)
{
- m_world.reset(new WorldMapGenerator<FeaturesCollector>(info));
+ m_world.reset(new WorldGenerator(info));
}
}
@@ -402,9 +405,8 @@ public:
}
else if (m_coastsHolder)
{
- CombinedEmitter<
- FeaturesCollector,
- Polygonizer<FeaturesCollector> > emitter(m_coastsHolder.get(), m_countries.get());
+ CombinedEmitter<FeaturesCollector, CountriesGenerator>
+ emitter(m_coastsHolder.get(), m_countries.get());
feature::ForEachFromDatRawFormat(m_srcCoastsFile, emitter);
}
@@ -414,7 +416,7 @@ public:
inline void GetNames(vector<string> & names) const
{
if (m_countries)
- names = m_countries->Names();
+ names = m_countries->Parent().Names();
else
names.clear();
}
diff --git a/generator/feature_merger.cpp b/generator/feature_merger.cpp
index 06c83b0193..e9c853cab8 100644
--- a/generator/feature_merger.cpp
+++ b/generator/feature_merger.cpp
@@ -322,14 +322,21 @@ namespace feature
class IsInvisibleFn
{
- int m_upperScale;
+ int m_lowScale, m_upScale;
+
public:
- IsInvisibleFn(int scale) : m_upperScale(scale) {}
+ IsInvisibleFn(int lowScale, int upScale)
+ : m_lowScale(lowScale), m_upScale(upScale)
+ {
+ }
+
bool operator() (uint32_t type) const
{
- int const startScale = feature::GetDrawableScaleRange(type).first;
+ pair<int, int> const range = feature::GetDrawableScaleRange(type);
+
// Actually it should not be equal to -1, but leave for safety reasons.
- return (startScale == -1 || startScale > m_upperScale);
+ return (range.first == -1 ||
+ range.first > m_upScale || range.second < m_lowScale);
}
};
@@ -337,7 +344,7 @@ bool PreprocessForWorldMap(FeatureBuilder1 & fb)
{
int const upperScale = scales::GetUpperWorldScale();
- if (fb.RemoveTypesIf(IsInvisibleFn(upperScale)))
+ if (fb.RemoveTypesIf(IsInvisibleFn(0, upperScale)))
return false;
fb.RemoveNameIfInvisible(0, upperScale);
@@ -345,4 +352,15 @@ bool PreprocessForWorldMap(FeatureBuilder1 & fb)
return true;
}
+bool PreprocessForCountryMap(FeatureBuilder1 & fb)
+{
+ if (fb.RemoveTypesIf(IsInvisibleFn(scales::GetUpperWorldScale() + 1,
+ scales::GetUpperStyleScale())))
+ {
+ return false;
+ }
+
+ return true;
+}
+
}
diff --git a/generator/feature_merger.hpp b/generator/feature_merger.hpp
index 5edbd0453a..7ad2436e38 100644
--- a/generator/feature_merger.hpp
+++ b/generator/feature_merger.hpp
@@ -119,5 +119,8 @@ public:
namespace feature
{
/// @return false If fb became invalid (no any suitable types).
+ //@{
bool PreprocessForWorldMap(FeatureBuilder1 & fb);
+ bool PreprocessForCountryMap(FeatureBuilder1 & fb);
+ //@}
}
diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp
index 9113d1d2fa..b5997d1566 100644
--- a/generator/feature_sorter.cpp
+++ b/generator/feature_sorter.cpp
@@ -50,11 +50,15 @@ namespace
m_midLoc = m_midLoc / m_locCount;
uint64_t const pointAsInt64 = PointToInt64(m_midLoc.x, m_midLoc.y, m_coordBits);
- uint64_t const minScale = feature::GetMinDrawableScale(ft.GetFeatureBase());
- CHECK(minScale <= scales::GetUpperStyleScale(), ("Dat file contain invisible feature"));
+ int const minScale = feature::GetMinDrawableScale(ft.GetFeatureBase());
- uint64_t const order = (minScale << 59) | (pointAsInt64 >> 5);
- m_vec.push_back(make_pair(order, pos));
+ /// 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).
+ if (minScale != -1)
+ {
+ uint64_t const order = (static_cast<uint64_t>(minScale) << 59) | (pointAsInt64 >> 5);
+ m_vec.push_back(make_pair(order, pos));
+ }
}
bool operator() (m2::PointD const & p)
diff --git a/generator/world_map_generator.hpp b/generator/world_map_generator.hpp
index 6eb05935a3..f2091c4081 100644
--- a/generator/world_map_generator.hpp
+++ b/generator/world_map_generator.hpp
@@ -110,3 +110,21 @@ public:
m_merger.DoMerge(m_worldBucket);
}
};
+
+template <class FeatureOutT>
+class CountryMapGenerator
+{
+ FeatureOutT m_bucket;
+
+public:
+ template <class TInfo>
+ explicit CountryMapGenerator(TInfo const & info) : m_bucket(info) {}
+
+ void operator()(FeatureBuilder1 fb)
+ {
+ if (feature::PreprocessForCountryMap(fb))
+ m_bucket(fb);
+ }
+
+ FeatureOutT const & Parent() const { return m_bucket; }
+};
diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp
index e8bb42168b..4dd2d65bec 100644
--- a/indexer/feature_data.cpp
+++ b/indexer/feature_data.cpp
@@ -267,11 +267,13 @@ uint32_t FeatureParams::GetTypeForIndex(uint32_t i)
string DebugPrint(FeatureParams const & p)
{
+ Classificator const & c = classif();
+
ostringstream out;
out << "Types: ";
for (size_t i = 0; i < p.m_Types.size(); ++i)
- out << p.m_Types[i] << "; ";
+ out << c.GetReadableObjectName(p.m_Types[i]) << "; ";
return (p.DebugString() + out.str());
}