diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2015-08-06 12:50:50 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:00:47 +0300 |
commit | 02a3ea65b7f0abdb15e62d116e29114db76c0651 (patch) | |
tree | 0d3386d75b7082b893937f8eeb2aedc374e1d75a /generator | |
parent | 8b2f3c3f445c9f9bb59ba8e094d92eb587e5753e (diff) |
Fix using fail_on_coasts flag
Diffstat (limited to 'generator')
-rw-r--r-- | generator/coastlines_generator.cpp | 7 | ||||
-rw-r--r-- | generator/generate_info.hpp | 4 | ||||
-rw-r--r-- | generator/generator_tool/generator_tool.cpp | 18 | ||||
-rw-r--r-- | generator/osm_source.cpp | 4 | ||||
-rw-r--r-- | generator/osm_source.hpp | 32 |
5 files changed, 57 insertions, 8 deletions
diff --git a/generator/coastlines_generator.cpp b/generator/coastlines_generator.cpp index 00fa7406d8..c1295bc639 100644 --- a/generator/coastlines_generator.cpp +++ b/generator/coastlines_generator.cpp @@ -8,8 +8,6 @@ #include "base/string_utils.hpp" #include "base/logging.hpp" -#include "3party/gflags/src/gflags/gflags.h" - #include "std/bind.hpp" #include "std/condition_variable.hpp" #include "std/function.hpp" @@ -20,8 +18,6 @@ typedef m2::RegionI RegionT; typedef m2::PointI PointT; typedef m2::RectI RectT; -DECLARE_bool(fail_on_coasts); - CoastlineFeaturesGenerator::CoastlineFeaturesGenerator(uint32_t coastType) : m_merger(POINT_COORD_BITS), m_coastType(coastType) { @@ -145,8 +141,7 @@ bool CoastlineFeaturesGenerator::Finish() { LOG(LINFO, ("Total not merged coasts:", doAdd.GetNotMergedCoastsCount())); LOG(LINFO, ("Total points in not merged coasts:", doAdd.GetNotMergedCoastsPoints())); - if (FLAGS_fail_on_coasts) - return false; + return false; } return true; diff --git a/generator/generate_info.hpp b/generator/generate_info.hpp index 9a0ebf6e60..94bbbabafb 100644 --- a/generator/generate_info.hpp +++ b/generator/generate_info.hpp @@ -46,8 +46,10 @@ struct GenerateInfo bool m_createWorld; bool m_splitByPolygons; - bool m_makeCoasts, m_emitCoasts; + bool m_makeCoasts; + bool m_emitCoasts; bool m_genAddresses; + bool m_failOnCoasts; GenerateInfo() diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index b2bcb93286..81a2e78fc4 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -99,6 +99,24 @@ int main(int argc, char ** argv) genInfo.m_tmpDir = tmpPath; } + genInfo.m_osmFileName = FLAGS_osm_file_name; + genInfo.m_failOnCoasts = FLAGS_fail_on_coasts; + + if (!FLAGS_node_storage.empty()) + genInfo.SetNodeStorageType(FLAGS_node_storage); + if (!FLAGS_osm_file_type.empty()) + genInfo.SetOsmFileType(FLAGS_osm_file_type); + + // Generating intermediate files + if (FLAGS_preprocess) + { + LOG(LINFO, ("Generating intermediate data ....")); + if (!GenerateIntermediateData(genInfo)) + { + return -1; + } + } + // load classificator only if necessary if (FLAGS_make_coasts || FLAGS_generate_features || FLAGS_generate_geometry || FLAGS_generate_index || FLAGS_generate_search_index || diff --git a/generator/osm_source.cpp b/generator/osm_source.cpp index 3a7c9100ae..705b3124f2 100644 --- a/generator/osm_source.cpp +++ b/generator/osm_source.cpp @@ -168,6 +168,7 @@ class MainFeaturesEmitter unique_ptr<feature::FeaturesCollector> m_coastsHolder; string m_srcCoastsFile; + bool m_failOnCoasts; enum TypeIndex { @@ -185,6 +186,7 @@ class MainFeaturesEmitter public: MainFeaturesEmitter(feature::GenerateInfo const & info) { + m_failOnCoasts = info.m_failOnCoasts; Classificator const & c = classif(); char const * arr[][2] = { @@ -267,7 +269,7 @@ public: if (m_coasts) { // Check and stop if some coasts were not merged - if (!m_coasts->Finish()) + if (!m_coasts->Finish() && m_failOnCoasts) return false; LOG(LINFO, ("Generating coastline polygons")); diff --git a/generator/osm_source.hpp b/generator/osm_source.hpp index e4ad42c197..8b79aa0711 100644 --- a/generator/osm_source.hpp +++ b/generator/osm_source.hpp @@ -2,7 +2,39 @@ #include "generator/generate_info.hpp" +#include "std/iostream.hpp" +#include "std/unique_ptr.hpp" + +class SourceReader +{ + struct Deleter + { + bool m_needDelete; + Deleter(bool needDelete = true) : m_needDelete(needDelete) {} + void operator()(istream * s) const + { + if (m_needDelete) + delete s; + } + }; + + string m_filename; + unique_ptr<istream, Deleter> m_file; + +public: + SourceReader(); + SourceReader(string const & filename); + SourceReader(istringstream & stream); + + uint64_t Read(char * buffer, uint64_t bufferSize); +}; + + + bool GenerateFeatures(feature::GenerateInfo & info); bool GenerateIntermediateData(feature::GenerateInfo & info); +class BaseOSMParser; + +void BuildFeaturesFromO5M(SourceReader & stream, BaseOSMParser & parser); |