reformat Extractor
This commit is contained in:
parent
8e73a4a19d
commit
3b9c6a6465
@ -122,15 +122,19 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
// {
|
// {
|
||||||
// SimpleLogger().Write(logWARNING) << "The recommended number of threads is "
|
// SimpleLogger().Write(logWARNING) << "The recommended number of threads is "
|
||||||
// << recommended_num_threads
|
// << recommended_num_threads
|
||||||
// << "! This setting may have performance side-effects.";
|
// << "! This setting may have performance
|
||||||
|
// side-effects.";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
auto number_of_threads = std::max(1,
|
auto number_of_threads =
|
||||||
std::min(static_cast<int>(recommended_num_threads), static_cast<int>(extractor_config.requested_num_threads)) );
|
std::max(1,
|
||||||
|
std::min(static_cast<int>(recommended_num_threads),
|
||||||
|
static_cast<int>(extractor_config.requested_num_threads)));
|
||||||
|
|
||||||
tbb::task_scheduler_init init(number_of_threads);
|
tbb::task_scheduler_init init(number_of_threads);
|
||||||
|
|
||||||
SimpleLogger().Write() << "requested_num_threads: " << extractor_config.requested_num_threads;
|
SimpleLogger().Write() << "requested_num_threads: "
|
||||||
|
<< extractor_config.requested_num_threads;
|
||||||
SimpleLogger().Write() << "number_of_threads: " << number_of_threads;
|
SimpleLogger().Write() << "number_of_threads: " << number_of_threads;
|
||||||
|
|
||||||
// setup scripting environment
|
// setup scripting environment
|
||||||
@ -180,7 +184,8 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
// initialize vectors holding parsed objects
|
// initialize vectors holding parsed objects
|
||||||
tbb::concurrent_vector<std::pair<std::size_t, ExtractionNode>> resulting_nodes;
|
tbb::concurrent_vector<std::pair<std::size_t, ExtractionNode>> resulting_nodes;
|
||||||
tbb::concurrent_vector<std::pair<std::size_t, ExtractionWay>> resulting_ways;
|
tbb::concurrent_vector<std::pair<std::size_t, ExtractionWay>> resulting_ways;
|
||||||
tbb::concurrent_vector<mapbox::util::optional<InputRestrictionContainer>> resulting_restrictions;
|
tbb::concurrent_vector<mapbox::util::optional<InputRestrictionContainer>>
|
||||||
|
resulting_restrictions;
|
||||||
|
|
||||||
// setup restriction parser
|
// setup restriction parser
|
||||||
RestrictionParser restriction_parser(scripting_environment.getLuaState());
|
RestrictionParser restriction_parser(scripting_environment.getLuaState());
|
||||||
@ -190,7 +195,7 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
// create a vector of iterators into the buffer
|
// create a vector of iterators into the buffer
|
||||||
std::vector<osmium::memory::Buffer::iterator> elements;
|
std::vector<osmium::memory::Buffer::iterator> elements;
|
||||||
osmium::memory::Buffer::iterator iter = std::begin(buffer);
|
osmium::memory::Buffer::iterator iter = std::begin(buffer);
|
||||||
while(iter != std::end(buffer))
|
while (iter != std::end(buffer))
|
||||||
{
|
{
|
||||||
elements.push_back(iter);
|
elements.push_back(iter);
|
||||||
iter = std::next(iter);
|
iter = std::next(iter);
|
||||||
@ -205,7 +210,7 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
|
|
||||||
// parse OSM entities in parallel, store in resulting vectors
|
// parse OSM entities in parallel, store in resulting vectors
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, elements.size()),
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, elements.size()),
|
||||||
[&](const tbb::blocked_range<std::size_t>& range)
|
[&](const tbb::blocked_range<std::size_t> &range)
|
||||||
{
|
{
|
||||||
for (auto x = range.begin(); x != range.end(); ++x)
|
for (auto x = range.begin(); x != range.end(); ++x)
|
||||||
{
|
{
|
||||||
@ -219,7 +224,8 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
case osmium::item_type::node:
|
case osmium::item_type::node:
|
||||||
++number_of_nodes;
|
++number_of_nodes;
|
||||||
result_node.Clear();
|
result_node.Clear();
|
||||||
luabind::call_function<void>(scripting_environment.getLuaState(),
|
luabind::call_function<void>(
|
||||||
|
scripting_environment.getLuaState(),
|
||||||
"node_function",
|
"node_function",
|
||||||
boost::cref(static_cast<osmium::Node &>(*entity)),
|
boost::cref(static_cast<osmium::Node &>(*entity)),
|
||||||
boost::ref(result_node));
|
boost::ref(result_node));
|
||||||
@ -228,7 +234,8 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
case osmium::item_type::way:
|
case osmium::item_type::way:
|
||||||
++number_of_ways;
|
++number_of_ways;
|
||||||
result_way.Clear();
|
result_way.Clear();
|
||||||
luabind::call_function<void>(scripting_environment.getLuaState(),
|
luabind::call_function<void>(
|
||||||
|
scripting_environment.getLuaState(),
|
||||||
"way_function",
|
"way_function",
|
||||||
boost::cref(static_cast<osmium::Way &>(*entity)),
|
boost::cref(static_cast<osmium::Way &>(*entity)),
|
||||||
boost::ref(result_way));
|
boost::ref(result_way));
|
||||||
@ -236,26 +243,27 @@ int Extractor::Run(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case osmium::item_type::relation:
|
case osmium::item_type::relation:
|
||||||
++number_of_relations;
|
++number_of_relations;
|
||||||
resulting_restrictions.emplace_back(restriction_parser.TryParse(scripting_environment.getLuaState(), static_cast<osmium::Relation &>(*entity)));
|
resulting_restrictions.emplace_back(
|
||||||
|
restriction_parser.TryParse(scripting_environment.getLuaState(),
|
||||||
|
static_cast<osmium::Relation &>(*entity)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
++number_of_others;
|
++number_of_others;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// put parsed objects thru extractor callbacks
|
// put parsed objects thru extractor callbacks
|
||||||
for (const auto &result : resulting_nodes)
|
for (const auto &result : resulting_nodes)
|
||||||
{
|
{
|
||||||
extractor_callbacks->ProcessNode(static_cast<osmium::Node &>(*(elements[result.first])),
|
extractor_callbacks->ProcessNode(
|
||||||
result.second);
|
static_cast<osmium::Node &>(*(elements[result.first])), result.second);
|
||||||
}
|
}
|
||||||
for (const auto &result : resulting_ways)
|
for (const auto &result : resulting_ways)
|
||||||
{
|
{
|
||||||
extractor_callbacks->ProcessWay(static_cast<osmium::Way &>(*(elements[result.first])),
|
extractor_callbacks->ProcessWay(
|
||||||
result.second);
|
static_cast<osmium::Way &>(*(elements[result.first])), result.second);
|
||||||
}
|
}
|
||||||
for (const auto &result : resulting_restrictions)
|
for (const auto &result : resulting_restrictions)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user