Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding nodes's and ways's version access in lua binding. #3373

Merged
merged 2 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/extractor/extractor_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ struct ExtractorConfig
bool generate_edge_lookup;
std::string edge_penalty_path;
std::string edge_segment_lookup_path;

bool use_metadata;
};
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/extractor/extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
auto extractor_callbacks = std::make_unique<ExtractorCallbacks>(extraction_containers);

const osmium::io::File input_file(config.input_path.string());
osmium::io::Reader reader(input_file, osmium::io::read_meta::no);

osmium::io::Reader reader(
input_file,
(config.use_metadata ? osmium::io::read_meta::yes : osmium::io::read_meta::no));

const osmium::io::Header header = reader.header();

unsigned number_of_nodes = 0;
Expand Down
8 changes: 6 additions & 2 deletions src/extractor/scripting_environment_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,19 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"id",
&osmium::Way::id,
"get_nodes",
[](const osmium::Way &way) { return sol::as_table(way.nodes()); });
[](const osmium::Way &way) { return sol::as_table(way.nodes()); },
"version",
&osmium::Way::version);

context.state.new_usertype<osmium::Node>("Node",
"location",
&osmium::Node::location,
"get_value_by_key",
&get_value_by_key<osmium::Node>,
"id",
&osmium::Node::id);
&osmium::Node::id,
"version",
&osmium::Way::version);

context.state.new_usertype<ExtractionNode>("ResultNode",
"traffic_lights",
Expand Down
7 changes: 6 additions & 1 deletion src/tools/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
boost::program_options::value<unsigned int>(&extractor_config.small_component_size)
->default_value(1000),
"Number of nodes required before a strongly-connected-componennt is considered big "
"(affects nearest neighbor snapping)");
"(affects nearest neighbor snapping)")(
"with-osm-metadata",
boost::program_options::value<bool>(&extractor_config.use_metadata)
->implicit_value(true)
->default_value(false),
"Use metada during osm parsing (This can affect the extraction performance).");

// hidden options, will be allowed on command line, but will not be
// shown to the user
Expand Down