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>2011-10-05 14:18:45 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:25:09 +0300
commit83494a171723c5cb86eb43f13bf5cc1e43d386b3 (patch)
treec00e12a3c0803db25fd42120645fdae53e6f3ad7 /generator/feature_generator.cpp
parent4e7ba7db28d5b87a265523ef2b0a961df69c5911 (diff)
Modify generation pipeline: add "make_coasts" and "emit_coasts" options to generate and get coastlines from different sources.
Diffstat (limited to 'generator/feature_generator.cpp')
-rw-r--r--generator/feature_generator.cpp67
1 files changed, 53 insertions, 14 deletions
diff --git a/generator/feature_generator.cpp b/generator/feature_generator.cpp
index af4b1379d5..95e89d19cd 100644
--- a/generator/feature_generator.cpp
+++ b/generator/feature_generator.cpp
@@ -251,30 +251,58 @@ public:
class MainFeaturesEmitter
{
- Polygonizer<FeaturesCollector> m_countries;
-
+ scoped_ptr<Polygonizer<FeaturesCollector> > m_countries;
scoped_ptr<WorldMapGenerator<FeaturesCollector> > m_world;
scoped_ptr<CoastlineFeaturesGenerator> m_coasts;
scoped_ptr<FeaturesCollector> m_coastsHolder;
+ string m_srcCoastsFile;
uint32_t m_coastType;
+ template <class T1, class T2> class CombinedEmitter
+ {
+ T1 * m_p1;
+ T2 * m_p2;
+ public:
+ CombinedEmitter(T1 * p1, T2 * p2) : m_p1(p1), m_p2(p2) {}
+ void operator() (FeatureBuilder1 const & fb, uint64_t)
+ {
+ if (m_p1) (*m_p1)(fb);
+ if (m_p2) (*m_p2)(fb);
+ }
+ };
+
public:
MainFeaturesEmitter(GenerateInfo const & info)
- : m_countries(info)
{
{
- static char const * path[] = {"natural", "coastline"};
+ static char const * path[] = { "natural", "coastline" };
m_coastType = classif().GetTypeByPath(vector<string>(path, path + 2));
}
- if (info.m_createWorld)
+ m_srcCoastsFile = info.m_tmpDir + WORLD_COASTS_FILE_NAME + info.m_datFileSuffix;
+
+ if (!info.m_makeCoasts)
+ {
+ m_countries.reset(new Polygonizer<FeaturesCollector>(info));
+
+ if (info.m_emitCoasts)
+ {
+ m_coastsHolder.reset(new FeaturesCollector(
+ info.m_datFilePrefix + WORLD_COASTS_FILE_NAME + info.m_datFileSuffix));
+ }
+ }
+ else
{
- m_world.reset(new WorldMapGenerator<FeaturesCollector>(info));
// 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));
+
+ m_coastsHolder.reset(new FeaturesCollector(m_srcCoastsFile));
+ }
+
+ if (info.m_createWorld)
+ {
+ m_world.reset(new WorldMapGenerator<FeaturesCollector>(info));
}
}
@@ -296,7 +324,8 @@ public:
if (m_world)
(*m_world)(fb);
- m_countries(fb);
+ if (m_countries)
+ (*m_countries)(fb);
}
}
@@ -315,15 +344,25 @@ public:
{
FeatureBuilder1 fb;
if (m_coasts->GetFeature(i, fb))
- {
(*m_coastsHolder)(fb);
- m_countries(fb);
- }
}
}
+ else if (m_coastsHolder)
+ {
+ CombinedEmitter<
+ FeaturesCollector,
+ Polygonizer<FeaturesCollector> > emitter(m_coastsHolder.get(), m_countries.get());
+ feature::ForEachFromDatRawFormat(m_srcCoastsFile, emitter);
+ }
}
- inline vector<string> const & GetNames() const { return m_countries.Names(); }
+ inline void GetNames(vector<string> & names) const
+ {
+ if (m_countries)
+ names = m_countries->Names();
+ else
+ names.clear();
+ }
};
}
@@ -344,7 +383,7 @@ bool GenerateImpl(GenerateInfo & info)
ParseXMLFromStdIn(parser);
bucketer.Finish();
- info.m_bucketNames = bucketer.GetNames();
+ bucketer.GetNames(info.m_bucketNames);
}
catch (Reader::Exception const & e)
{