forked from organicmaps/organicmaps
Pass scale range of mwm to index building routine.
This commit is contained in:
parent
ded59b69b8
commit
36ecd0526d
4 changed files with 16 additions and 6 deletions
|
@ -24,7 +24,7 @@ namespace indexer
|
|||
|
||||
FeaturesVector featuresVector(readCont, header);
|
||||
|
||||
BuildIndex(header.GetLastScale() + 1, featuresVector, writer, tmpFile);
|
||||
BuildIndex(header.GetLastScale() + 1, header.GetScaleRange(), featuresVector, writer, tmpFile);
|
||||
}
|
||||
catch (Reader::Exception const & e)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace indexer
|
|||
{
|
||||
template <class FeaturesVectorT, typename WriterT>
|
||||
void BuildIndex(uint32_t bucketsCount,
|
||||
pair<int, int> const & scaleRange,
|
||||
FeaturesVectorT const & featuresVector,
|
||||
WriterT & writer,
|
||||
string const & tmpFilePrefix)
|
||||
|
@ -14,7 +15,7 @@ namespace indexer
|
|||
uint64_t indexSize;
|
||||
{
|
||||
SubWriter<WriterT> subWriter(writer);
|
||||
IndexScales(bucketsCount, featuresVector, subWriter, tmpFilePrefix);
|
||||
IndexScales(bucketsCount, scaleRange, featuresVector, subWriter, tmpFilePrefix);
|
||||
indexSize = subWriter.Size();
|
||||
}
|
||||
LOG(LINFO, ("Built scale index. Size =", indexSize));
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../index_builder.hpp"
|
||||
#include "../classificator_loader.hpp"
|
||||
#include "../features_vector.hpp"
|
||||
#include "../scales.hpp"
|
||||
|
||||
#include "../../defines.hpp"
|
||||
|
||||
|
@ -33,7 +34,9 @@ UNIT_TEST(BuildIndexTest)
|
|||
FeaturesVector featuresVector(originalContainer, header);
|
||||
|
||||
MemWriter<vector<char> > serialWriter(serialIndex);
|
||||
indexer::BuildIndex(ScaleIndexBase::NUM_BUCKETS, featuresVector, serialWriter,
|
||||
indexer::BuildIndex(ScaleIndexBase::NUM_BUCKETS,
|
||||
make_pair(0, scales::GetUpperScale()),
|
||||
featuresVector, serialWriter,
|
||||
"build_index_test");
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,11 @@ class FeatureCoverer
|
|||
|
||||
public:
|
||||
FeatureCoverer(uint32_t bucket,
|
||||
pair<int, int> const & scaleRange,
|
||||
SorterT & sorter,
|
||||
uint32_t & numFeatures) :
|
||||
m_Sorter(sorter),
|
||||
uint32_t & numFeatures)
|
||||
: m_Sorter(sorter),
|
||||
m_mwmScaleRange(scaleRange),
|
||||
m_ScaleRange(ScaleIndexBase::ScaleRangeForBucket(bucket)),
|
||||
m_NumFeatures(numFeatures)
|
||||
{
|
||||
|
@ -69,7 +71,9 @@ public:
|
|||
{
|
||||
if (FeatureShouldBeIndexed(f))
|
||||
{
|
||||
/// @todo Use m_mwmScaleRange to make better covering.
|
||||
vector<int64_t> const cells = covering::CoverFeature(f, RectId::DEPTH_LEVELS, 250);
|
||||
|
||||
for (vector<int64_t>::const_iterator it = cells.begin(); it != cells.end(); ++it)
|
||||
m_Sorter.Add(CellFeaturePair(*it, offset));
|
||||
++m_NumFeatures;
|
||||
|
@ -89,6 +93,7 @@ public:
|
|||
|
||||
private:
|
||||
SorterT & m_Sorter;
|
||||
pair<int, int> m_mwmScaleRange;
|
||||
pair<uint32_t, uint32_t> m_ScaleRange;
|
||||
uint32_t & m_NumFeatures;
|
||||
};
|
||||
|
@ -112,6 +117,7 @@ private:
|
|||
|
||||
template <class FeaturesVectorT, class WriterT>
|
||||
inline void IndexScales(uint32_t bucketsCount,
|
||||
pair<int, int> const & scaleRange,
|
||||
FeaturesVectorT const & featuresVector,
|
||||
WriterT & writer,
|
||||
string const & tmpFilePrefix)
|
||||
|
@ -133,7 +139,7 @@ inline void IndexScales(uint32_t bucketsCount,
|
|||
WriterFunctor<FileWriter> out(cellsToFeaturesWriter);
|
||||
SorterType sorter(1024*1024, tmpFilePrefix + ".c2f.tmp", out);
|
||||
featuresVector.ForEachOffset(
|
||||
FeatureCoverer<SorterType>(bucket, sorter, numFeatures));
|
||||
FeatureCoverer<SorterType>(bucket, scaleRange, sorter, numFeatures));
|
||||
// LOG(LINFO, ("Sorting..."));
|
||||
sorter.SortAndFinish();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue