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:
-rw-r--r--generator/feature_generator.cpp67
-rw-r--r--generator/generate_info.hpp10
-rw-r--r--generator/generator_tool/generator_tool.cpp13
3 files changed, 71 insertions, 19 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)
{
diff --git a/generator/generate_info.hpp b/generator/generate_info.hpp
index 40bd96cf87..914c2218e3 100644
--- a/generator/generate_info.hpp
+++ b/generator/generate_info.hpp
@@ -8,13 +8,21 @@ namespace feature
struct GenerateInfo
{
- GenerateInfo() : m_createWorld(false), m_splitByPolygons(false) {}
+ GenerateInfo()
+ : m_createWorld(false), m_splitByPolygons(false),
+ m_makeCoasts(false), m_emitCoasts(false)
+ {
+ }
+
string m_tmpDir;
string m_datFilePrefix;
string m_datFileSuffix;
+
vector<string> m_bucketNames;
+
bool m_createWorld;
bool m_splitByPolygons;
+ bool m_makeCoasts, m_emitCoasts;
};
} // namespace feature
diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp
index 61bccac2f0..99e5c60984 100644
--- a/generator/generator_tool/generator_tool.cpp
+++ b/generator/generator_tool/generator_tool.cpp
@@ -32,8 +32,12 @@
DEFINE_bool(version, false, "Display version");
DEFINE_bool(generate_update, false,
"If specified, update.maps file will be generated from cells in the data path");
+
DEFINE_bool(generate_classif, false, "Generate classificator.");
DEFINE_bool(preprocess_xml, false, "1st pass - create nodes/ways/relations data");
+DEFINE_bool(make_coasts, false, "create intermediate file with coasts data");
+DEFINE_bool(emit_coasts, false, "push coasts features from intermediate file to out files/countries");
+
DEFINE_bool(generate_features, false, "2nd pass - generate intermediate features");
DEFINE_bool(generate_geometry, false, "3rd pass - split and simplify geometry and triangles for features");
DEFINE_bool(generate_index, false, "4rd pass - generate index");
@@ -104,7 +108,7 @@ int main(int argc, char ** argv)
genInfo.m_tmpDir = FLAGS_intermediate_data_path;
// load classificator only if necessary
- if (FLAGS_generate_features || FLAGS_generate_geometry ||
+ if (FLAGS_make_coasts || FLAGS_generate_features || FLAGS_generate_geometry ||
FLAGS_generate_index || FLAGS_generate_search_index ||
FLAGS_calc_statistics || FLAGS_dump_types || FLAGS_dump_prefixes)
{
@@ -116,7 +120,7 @@ int main(int argc, char ** argv)
}
// Generate dat file
- if (FLAGS_generate_features)
+ if (FLAGS_generate_features || FLAGS_make_coasts)
{
LOG(LINFO, ("Generating final data ..."));
@@ -124,12 +128,13 @@ int main(int argc, char ** argv)
genInfo.m_datFilePrefix = path;
else
genInfo.m_datFilePrefix = path + FLAGS_output;
+
genInfo.m_datFileSuffix = DATA_FILE_EXTENSION;
- // split data by countries polygons
genInfo.m_splitByPolygons = FLAGS_split_by_polygons;
-
genInfo.m_createWorld = FLAGS_generate_world;
+ genInfo.m_makeCoasts = FLAGS_make_coasts;
+ genInfo.m_emitCoasts = FLAGS_emit_coasts;
if (!feature::GenerateFeatures(genInfo, FLAGS_use_light_nodes))
return -1;