From 48b2a4729af73c4184a477b992d4c6f0cbb4e9df Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Sun, 9 Jan 2011 04:50:01 +0200 Subject: [PATCH] [indexer_tool] Added boolean --world_only flag to allow only world file generation --- indexer/indexer_tool/feature_bucketer.hpp | 52 +++++++++++++--------- indexer/indexer_tool/feature_generator.cpp | 3 +- indexer/indexer_tool/feature_generator.hpp | 3 +- indexer/indexer_tool/indexer_tool.cpp | 2 + 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/indexer/indexer_tool/feature_bucketer.hpp b/indexer/indexer_tool/feature_bucketer.hpp index 7d7a9df703..ecfcbc4f58 100644 --- a/indexer/indexer_tool/feature_bucketer.hpp +++ b/indexer/indexer_tool/feature_bucketer.hpp @@ -26,19 +26,22 @@ class CellFeatureBucketer public: CellFeatureBucketer(int level, typename FeatureOutT::InitDataType const & featureOutInitData, - int maxWorldZoom = -1) - : m_Level(level), m_FeatureOutInitData(featureOutInitData), m_maxWorldZoom(maxWorldZoom) + int maxWorldZoom = -1, bool worldOnly = false) + : m_Level(level), m_FeatureOutInitData(featureOutInitData), m_maxWorldZoom(maxWorldZoom), + m_worldOnly(worldOnly) { - uint32_t const size = 1 << 2 * m_Level; - m_Buckets.resize(size); - for (uint32_t i = 0; i < m_Buckets.size(); ++i) + if (!m_worldOnly) { - CellIdT cell = CellIdT::FromBitsAndLevel(i, m_Level); - double minX, minY, maxX, maxY; - CellIdConverter::GetCellBounds(cell, minX, minY, maxX, maxY); - m_Buckets[i].m_Rect = m2::RectD(minX, minY, maxX, maxY); + uint32_t const size = 1 << 2 * m_Level; + m_Buckets.resize(size); + for (uint32_t i = 0; i < m_Buckets.size(); ++i) + { + CellIdT cell = CellIdT::FromBitsAndLevel(i, m_Level); + double minX, minY, maxX, maxY; + CellIdConverter::GetCellBounds(cell, minX, minY, maxX, maxY); + m_Buckets[i].m_Rect = m2::RectD(minX, minY, maxX, maxY); + } } - // create separate world bucket if necessary if (maxWorldZoom >= 0) m_worldBucket.reset(new FeatureOutT(WORLD_FILE_NAME, m_FeatureOutInitData)); @@ -50,22 +53,25 @@ public: if (m_worldBucket && m_maxWorldZoom >= feature::MinDrawableScaleForFeature(fb.GetFeatureBase())) (*m_worldBucket)(fb); - FeatureClipperT clipper(fb); - // TODO: Is feature fully inside GetLimitRect()? - m2::RectD const limitRect = fb.GetLimitRect(); - for (uint32_t i = 0; i < m_Buckets.size(); ++i) + if (!m_worldOnly) { - // First quick and dirty limit rect intersection. - // Clipper may (or may not) do a better intersection. - if (m_Buckets[i].m_Rect.IsIntersect(limitRect)) + FeatureClipperT clipper(fb); + // TODO: Is feature fully inside GetLimitRect()? + m2::RectD const limitRect = fb.GetLimitRect(); + for (uint32_t i = 0; i < m_Buckets.size(); ++i) { - feature_builder_t clippedFb; - if (clipper(m_Buckets[i].m_Rect, clippedFb)) + // First quick and dirty limit rect intersection. + // Clipper may (or may not) do a better intersection. + if (m_Buckets[i].m_Rect.IsIntersect(limitRect)) { - if (!m_Buckets[i].m_pOut) - m_Buckets[i].m_pOut = new FeatureOutT(BucketName(i), m_FeatureOutInitData); + feature_builder_t clippedFb; + if (clipper(m_Buckets[i].m_Rect, clippedFb)) + { + if (!m_Buckets[i].m_pOut) + m_Buckets[i].m_pOut = new FeatureOutT(BucketName(i), m_FeatureOutInitData); - (*(m_Buckets[i].m_pOut))(clippedFb); + (*(m_Buckets[i].m_pOut))(clippedFb); + } } } } @@ -99,6 +105,8 @@ private: /// if NULL, separate world data file is not generated boost::scoped_ptr m_worldBucket; int m_maxWorldZoom; + /// if true, only world features will be written + bool m_worldOnly; }; class SimpleFeatureClipper diff --git a/indexer/indexer_tool/feature_generator.cpp b/indexer/indexer_tool/feature_generator.cpp index e2dd878663..74cad6c2aa 100644 --- a/indexer/indexer_tool/feature_generator.cpp +++ b/indexer/indexer_tool/feature_generator.cpp @@ -301,7 +301,8 @@ bool GenerateImpl(GenerateInfo & info) typedef CellFeatureBucketer FeatureBucketerType; - FeatureBucketerType bucketer(info.cellBucketingLevel, collectorInitData, info.m_maxScaleForWorldFeatures); + FeatureBucketerType bucketer(info.cellBucketingLevel, collectorInitData, + info.m_maxScaleForWorldFeatures, info.m_worldOnly); { TParser parser(bucketer, holder); ParseXMLFromStdIn(parser); diff --git a/indexer/indexer_tool/feature_generator.hpp b/indexer/indexer_tool/feature_generator.hpp index b7914a9abb..b7c5c58276 100644 --- a/indexer/indexer_tool/feature_generator.hpp +++ b/indexer/indexer_tool/feature_generator.hpp @@ -15,7 +15,7 @@ namespace feature { struct GenerateInfo { - GenerateInfo() : m_maxScaleForWorldFeatures(-1) {} + GenerateInfo() : m_maxScaleForWorldFeatures(-1), m_worldOnly(false) {} string dir, datFilePrefix, datFileSuffix; int cellBucketingLevel; vector bucketNames; @@ -23,6 +23,7 @@ namespace feature /// included into separate world data file /// @note if -1, world file will not be created int m_maxScaleForWorldFeatures; + bool m_worldOnly; }; bool GenerateFeatures(GenerateInfo & info, bool lightNodes); diff --git a/indexer/indexer_tool/indexer_tool.cpp b/indexer/indexer_tool/indexer_tool.cpp index 49d7375c6f..7d548ac77b 100644 --- a/indexer/indexer_tool/indexer_tool.cpp +++ b/indexer/indexer_tool/indexer_tool.cpp @@ -47,6 +47,7 @@ DEFINE_string(intermediate_data_path, "", "Path to store nodes, ways, relations. DEFINE_int32(bucketing_level, 7, "Level of cell ids for bucketing."); DEFINE_int32(worldmap_max_zoom, -1, "If specified, features for zoomlevels [0..this_value] " " which are enabled in classificator will be added to the separate world.map"); +DEFINE_bool(world_only, false, "Generate only world features for given worldmap_max_zoom"); string AddSlashIfNeeded(string const & str) { @@ -123,6 +124,7 @@ int main(int argc, char ** argv) genInfo.datFileSuffix = DATA_FILE_EXTENSION; genInfo.cellBucketingLevel = FLAGS_bucketing_level; genInfo.m_maxScaleForWorldFeatures = FLAGS_worldmap_max_zoom; + genInfo.m_worldOnly = FLAGS_world_only; if (!feature::GenerateFeatures(genInfo, FLAGS_use_light_nodes)) {