reformat Extractor

This commit is contained in:
Dennis Luxen 2014-11-18 19:03:44 +01:00
parent 8e73a4a19d
commit 3b9c6a6465

View File

@ -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());
@ -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)
{ {