[indexer_tool] Removed -world_only flag

This commit is contained in:
Alex Zolotarev 2011-02-05 03:22:24 +02:00 committed by Alex Zolotarev
parent db10d5fbfc
commit 5a53cee689
5 changed files with 48 additions and 51 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include "../../base/base.hpp"
#include "../../base/logging.hpp"
#include "../../coding/file_writer.hpp"
@ -25,17 +26,14 @@ class CellFeatureBucketer
void Init()
{
if (!m_worldOnly)
uint32_t const size = 1 << 2 * m_Level;
m_Buckets.resize(size);
for (uint32_t i = 0; i < m_Buckets.size(); ++i)
{
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<BoundsT, CellIdT>::GetCellBounds(cell, minX, minY, maxX, maxY);
m_Buckets[i].m_Rect = m2::RectD(minX, minY, maxX, maxY);
}
CellIdT cell = CellIdT::FromBitsAndLevel(i, m_Level);
double minX, minY, maxX, maxY;
CellIdConverter<BoundsT, CellIdT>::GetCellBounds(cell, minX, minY, maxX, maxY);
m_Buckets[i].m_Rect = m2::RectD(minX, minY, maxX, maxY);
}
// create separate world bucket if necessary
if (m_maxWorldZoom >= 0)
@ -46,42 +44,45 @@ public:
template <class TInfo>
explicit CellFeatureBucketer(TInfo & info)
: m_Level(info.cellBucketingLevel), m_FeatureOutInitData(info.datFilePrefix, info.datFileSuffix),
m_maxWorldZoom(info.m_maxScaleForWorldFeatures), m_worldOnly(info.m_worldOnly)
m_maxWorldZoom(info.maxScaleForWorldFeatures)
{
Init();
}
CellFeatureBucketer(int level, typename FeatureOutT::InitDataType const & initData)
: m_Level(level), m_FeatureOutInitData(initData), m_maxWorldZoom(-1), m_worldOnly(false)
: m_Level(level), m_FeatureOutInitData(initData), m_maxWorldZoom(-1)
{
Init();
}
void operator () (feature_builder_t const & fb)
{
int minScale = feature::MinDrawableScaleForFeature(fb.GetFeatureBase());
if (minScale == -1)
{
LOG(LWARNING, ("Non-drawable feature found, ignoring"));
return;
}
// separately store features needed for world map
if (m_worldBucket && m_maxWorldZoom >= feature::MinDrawableScaleForFeature(fb.GetFeatureBase()))
if (m_worldBucket && m_maxWorldZoom >= minScale)
(*m_worldBucket)(fb);
if (!m_worldOnly)
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)
{
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)
// First quick and dirty limit rect intersection.
// Clipper may (or may not) do a better intersection.
if (m_Buckets[i].m_Rect.IsIntersect(limitRect))
{
// First quick and dirty limit rect intersection.
// Clipper may (or may not) do a better intersection.
if (m_Buckets[i].m_Rect.IsIntersect(limitRect))
feature_builder_t clippedFb;
if (clipper(m_Buckets[i].m_Rect, clippedFb))
{
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);
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);
}
}
}
@ -115,8 +116,6 @@ private:
/// if NULL, separate world data file is not generated
boost::scoped_ptr<FeatureOutT> m_worldBucket;
int m_maxWorldZoom;
/// if true, only world features will be written
bool m_worldOnly;
};
class SimpleFeatureClipper

View file

@ -288,14 +288,14 @@ bool GenerateImpl(GenerateInfo & info)
{
try
{
TNodesHolder nodes(info.dir + NODES_FILE);
TNodesHolder nodes(info.tmpDir + NODES_FILE);
typedef FileHolder<TNodesHolder> holder_t;
holder_t holder(nodes, info.dir);
holder_t holder(nodes, info.tmpDir);
holder.LoadIndex();
if (info.m_splitByPolygons)
if (info.splitByPolygons)
{
typedef Polygonizer<FeaturesCollector, MercatorBounds, RectId> FeaturePolygonizerType;
// prefix is data dir

View file

@ -16,18 +16,18 @@ namespace feature
struct GenerateInfo
{
GenerateInfo()
: m_maxScaleForWorldFeatures(-1), m_worldOnly(false), m_splitByPolygons(false),
m_simplifyCountriesLevel(-1) {}
string dir, datFilePrefix, datFileSuffix;
: maxScaleForWorldFeatures(-1), splitByPolygons(false),
simplifyCountriesLevel(-1) {}
string tmpDir, datFilePrefix, datFileSuffix;
/// If not -1, world will be split by buckets with specified level
int cellBucketingLevel;
vector<string> bucketNames;
/// Features with scale level [0..maxScaleForWorldFeatures] will be
/// included into separate world data file
/// @note if -1, world file will not be created
int m_maxScaleForWorldFeatures;
bool m_worldOnly;
bool m_splitByPolygons;
int m_simplifyCountriesLevel;
int maxScaleForWorldFeatures;
bool splitByPolygons;
int simplifyCountriesLevel;
};
bool GenerateFeatures(GenerateInfo & info, bool lightNodes);

View file

@ -44,10 +44,9 @@ DEFINE_bool(use_light_nodes, false,
DEFINE_string(data_path, "", "Working directory, 'path_to_exe/../../data' if empty.");
DEFINE_string(output, "", "Prefix of filenames of outputted .dat and .idx files.");
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");
DEFINE_int32(bucketing_level, -1, "If positive, level of cell ids for bucketing.");
DEFINE_int32(generate_world_scale, -1, "If specified, features for zoomlevels [0..this_value] "
"which are enabled in classificator will be MOVED to the separate world file");
DEFINE_bool(split_by_polygons, false, "Use kml shape files to split planet by regions and countries");
DEFINE_int32(simplify_countries_level, -1, "If positive, simplifies country polygons. Recommended values [10..15]");
@ -102,7 +101,7 @@ int main(int argc, char ** argv)
}
feature::GenerateInfo genInfo;
genInfo.dir = FLAGS_intermediate_data_path;
genInfo.tmpDir = FLAGS_intermediate_data_path;
// load classificator only if necessary
if (FLAGS_generate_features || FLAGS_generate_geometry ||
@ -126,19 +125,18 @@ int main(int argc, char ** argv)
genInfo.datFileSuffix = DATA_FILE_EXTENSION;
// split data by countries polygons
genInfo.m_splitByPolygons = FLAGS_split_by_polygons;
genInfo.m_simplifyCountriesLevel = FLAGS_simplify_countries_level;
genInfo.splitByPolygons = FLAGS_split_by_polygons;
genInfo.simplifyCountriesLevel = FLAGS_simplify_countries_level;
genInfo.cellBucketingLevel = FLAGS_bucketing_level;
genInfo.m_maxScaleForWorldFeatures = FLAGS_worldmap_max_zoom;
genInfo.m_worldOnly = FLAGS_world_only;
genInfo.maxScaleForWorldFeatures = FLAGS_generate_world_scale;
if (!feature::GenerateFeatures(genInfo, FLAGS_use_light_nodes))
return -1;
for (size_t i = 0; i < genInfo.bucketNames.size(); ++i)
genInfo.bucketNames[i] = genInfo.datFilePrefix + genInfo.bucketNames[i] + genInfo.datFileSuffix;
if (FLAGS_worldmap_max_zoom >= 0)
if (FLAGS_generate_world_scale >= 0)
genInfo.bucketNames.push_back(genInfo.datFilePrefix + WORLD_FILE_NAME + genInfo.datFileSuffix);
}
else

View file

@ -29,7 +29,7 @@ namespace feature
Polygonizer(TInfo & info)
: m_FeatureOutInitData(info.datFilePrefix, info.datFileSuffix), m_Names(info.bucketNames)
{
CHECK(kml::LoadCountriesList(info.datFilePrefix, m_countries, info.m_simplifyCountriesLevel),
CHECK(kml::LoadCountriesList(info.datFilePrefix, m_countries, info.simplifyCountriesLevel),
("Error loading polygons"));
//LOG_SHORT(LINFO, ("Loaded polygons count for regions:"));