forked from organicmaps/organicmaps
[indexer_tool] Added boolean --world_only flag to allow only world file generation
This commit is contained in:
parent
9ebb6fb4b9
commit
48b2a4729a
4 changed files with 36 additions and 24 deletions
|
@ -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<BoundsT, CellIdT>::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<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 (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<FeatureOutT> m_worldBucket;
|
||||
int m_maxWorldZoom;
|
||||
/// if true, only world features will be written
|
||||
bool m_worldOnly;
|
||||
};
|
||||
|
||||
class SimpleFeatureClipper
|
||||
|
|
|
@ -301,7 +301,8 @@ bool GenerateImpl(GenerateInfo & info)
|
|||
|
||||
typedef CellFeatureBucketer<FeaturesCollector, SimpleFeatureClipper, MercatorBounds, RectId>
|
||||
FeatureBucketerType;
|
||||
FeatureBucketerType bucketer(info.cellBucketingLevel, collectorInitData, info.m_maxScaleForWorldFeatures);
|
||||
FeatureBucketerType bucketer(info.cellBucketingLevel, collectorInitData,
|
||||
info.m_maxScaleForWorldFeatures, info.m_worldOnly);
|
||||
{
|
||||
TParser<FeatureBucketerType, holder_t> parser(bucketer, holder);
|
||||
ParseXMLFromStdIn(parser);
|
||||
|
|
|
@ -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<string> 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);
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue