forked from organicmaps/organicmaps
Code fix
This commit is contained in:
parent
67a465c565
commit
45610d1dcf
3 changed files with 10 additions and 25 deletions
|
@ -22,12 +22,9 @@ typedef m2::RectI RectT;
|
|||
|
||||
DECLARE_bool(fail_on_coasts);
|
||||
|
||||
CoastlineFeaturesGenerator::CoastlineFeaturesGenerator(uint32_t coastType,
|
||||
int lowLevel, int highLevel, int maxPoints)
|
||||
: m_merger(POINT_COORD_BITS), m_coastType(coastType),
|
||||
m_lowLevel(lowLevel), m_highLevel(highLevel), m_maxPoints(maxPoints)
|
||||
CoastlineFeaturesGenerator::CoastlineFeaturesGenerator(uint32_t coastType)
|
||||
: m_merger(POINT_COORD_BITS), m_coastType(coastType)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL ( m_lowLevel, m_highLevel, () );
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -221,11 +218,12 @@ public:
|
|||
typedef m4::Tree<m2::RegionI> TIndex;
|
||||
typedef function<void(TCell const &, DoDifference &)> TProcessResultFunc;
|
||||
|
||||
enum {kHighLevel = 10, kMaxPoints = 20000};
|
||||
|
||||
protected:
|
||||
TIndex const & m_index;
|
||||
mutex & m_mutexTasks;
|
||||
list<TCell> & m_listTasks;
|
||||
list<TCell> m_errorCell;
|
||||
condition_variable & m_listCondVar;
|
||||
size_t & m_inWork;
|
||||
TProcessResultFunc m_processResultFunc;
|
||||
|
@ -288,7 +286,7 @@ public:
|
|||
m_index.ForEachInRect(GetLimitRect(rectR), bind<void>(ref(doDiff), _1));
|
||||
|
||||
// Check if too many points for feature.
|
||||
if (cell.Level() < 10 /*m_highLevel*/ && doDiff.GetPointsCount() >= 20000 /*m_maxPoints*/)
|
||||
if (cell.Level() < kHighLevel && doDiff.GetPointsCount() >= kMaxPoints)
|
||||
return false;
|
||||
|
||||
{
|
||||
|
@ -297,7 +295,6 @@ public:
|
|||
m_processResultFunc(cell, doDiff);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -307,13 +304,12 @@ public:
|
|||
// thread main loop
|
||||
for (;;)
|
||||
{
|
||||
TCell currentCell;
|
||||
unique_lock<mutex> lock(m_mutexTasks);
|
||||
m_listCondVar.wait(lock, [this]{return (!m_listTasks.empty() || m_inWork == 0);});
|
||||
if (m_listTasks.empty() && m_inWork == 0)
|
||||
break;
|
||||
|
||||
currentCell = m_listTasks.front();
|
||||
TCell currentCell = m_listTasks.front();
|
||||
m_listTasks.pop_front();
|
||||
++m_inWork;
|
||||
lock.unlock();
|
||||
|
@ -330,13 +326,6 @@ public:
|
|||
--m_inWork;
|
||||
m_listCondVar.notify_all();
|
||||
}
|
||||
|
||||
// return back cells with error into task queue
|
||||
if (!m_errorCell.empty())
|
||||
{
|
||||
unique_lock<mutex> lock(m_mutexTasks);
|
||||
m_listTasks.insert(m_listTasks.end(), m_errorCell.begin(), m_errorCell.end());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -349,7 +338,7 @@ void CoastlineFeaturesGenerator::GetFeatures(size_t baseLevel, vector<FeatureBui
|
|||
{
|
||||
features.emplace_back(FeatureBuilder1());
|
||||
FeatureBuilder1 & fb = features.back();
|
||||
fb.SetCoastCell(cell.ToInt64(m_highLevel + 1), cell.ToString());
|
||||
fb.SetCoastCell(cell.ToInt64(RegionInCellSplitter::kHighLevel + 1), cell.ToString());
|
||||
|
||||
cellData.AssignGeometry(fb);
|
||||
fb.SetArea();
|
||||
|
|
|
@ -18,11 +18,9 @@ class CoastlineFeaturesGenerator
|
|||
TTree m_tree;
|
||||
|
||||
uint32_t m_coastType;
|
||||
int m_lowLevel, m_highLevel, m_maxPoints;
|
||||
|
||||
public:
|
||||
CoastlineFeaturesGenerator(uint32_t coastType,
|
||||
int lowLevel, int highLevel, int maxPoints);
|
||||
CoastlineFeaturesGenerator(uint32_t coastType);
|
||||
|
||||
void AddRegionToTree(FeatureBuilder1 const & fb);
|
||||
|
||||
|
|
|
@ -240,9 +240,7 @@ namespace
|
|||
}
|
||||
else
|
||||
{
|
||||
// 4-10 - level range for cells
|
||||
// 20000 - max points count per feature
|
||||
m_coasts.reset(new CoastlineFeaturesGenerator(Type(NATURAL_COASTLINE), 4, 10, 20000));
|
||||
m_coasts.reset(new CoastlineFeaturesGenerator(Type(NATURAL_COASTLINE)));
|
||||
|
||||
m_coastsHolder.reset(new feature::FeaturesAndRawGeometryCollector(
|
||||
m_srcCoastsFile, info.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, ".rawdump")));
|
||||
|
@ -311,7 +309,7 @@ namespace
|
|||
size_t totalPolygons = 0;
|
||||
|
||||
vector<FeatureBuilder1> vecFb;
|
||||
m_coasts->GetFeatures(4 /*m_lowLevel*/, vecFb);
|
||||
m_coasts->GetFeatures(4 /*start level*/, vecFb);
|
||||
|
||||
for (size_t j = 0; j < vecFb.size(); ++j)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue