revert format changes

This commit is contained in:
Matt Bhagat-Conway 2023-03-03 09:19:49 -05:00
parent 76e2d48e1b
commit a4055091dd
No known key found for this signature in database
GPG Key ID: EB64FF36E7DA441A

View File

@ -245,8 +245,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"valid", "valid",
&osmium::Location::valid); &osmium::Location::valid);
auto get_location_tag = [](auto &context, const auto &location, const char *key) auto get_location_tag = [](auto &context, const auto &location, const char *key) {
{
if (context.location_dependent_data.empty()) if (context.location_dependent_data.empty())
return sol::object(context.state); return sol::object(context.state);
@ -273,8 +272,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"get_nodes", "get_nodes",
[](const osmium::Way &way) { return sol::as_table(&way.nodes()); }, [](const osmium::Way &way) { return sol::as_table(&way.nodes()); },
"get_location_tag", "get_location_tag",
[&context, &get_location_tag](const osmium::Way &way, const char *key) [&context, &get_location_tag](const osmium::Way &way, const char *key) {
{
// HEURISTIC: use a single node (last) of the way to localize the way // HEURISTIC: use a single node (last) of the way to localize the way
// For more complicated scenarios a proper merging of multiple tags // For more complicated scenarios a proper merging of multiple tags
// at one or many locations must be provided // at one or many locations must be provided
@ -294,8 +292,9 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"version", "version",
&osmium::Node::version, &osmium::Node::version,
"get_location_tag", "get_location_tag",
[&context, &get_location_tag](const osmium::Node &node, const char *key) [&context, &get_location_tag](const osmium::Node &node, const char *key) {
{ return get_location_tag(context, node.location(), key); }); return get_location_tag(context, node.location(), key);
});
context.state.new_enum("traffic_lights", context.state.new_enum("traffic_lights",
"none", "none",
@ -311,8 +310,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"ResultNode", "ResultNode",
"traffic_lights", "traffic_lights",
sol::property([](const ExtractionNode &node) { return node.traffic_lights; }, sol::property([](const ExtractionNode &node) { return node.traffic_lights; },
[](ExtractionNode &node, const sol::object &obj) [](ExtractionNode &node, const sol::object &obj) {
{
if (obj.is<bool>()) if (obj.is<bool>())
{ {
// The old approach of assigning a boolean traffic light // The old approach of assigning a boolean traffic light
@ -363,8 +361,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
sol::property(&ExtractionWay::GetName, &ExtractionWay::SetName), sol::property(&ExtractionWay::GetName, &ExtractionWay::SetName),
"ref", // backward compatibility "ref", // backward compatibility
sol::property(&ExtractionWay::GetForwardRef, sol::property(&ExtractionWay::GetForwardRef,
[](ExtractionWay &way, const char *ref) [](ExtractionWay &way, const char *ref) {
{
way.SetForwardRef(ref); way.SetForwardRef(ref);
way.SetBackwardRef(ref); way.SetBackwardRef(ref);
}), }),
@ -423,8 +420,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
sol::property([](const ExtractionWay &way) { return way.access_turn_classification; }, sol::property([](const ExtractionWay &way) { return way.access_turn_classification; },
[](ExtractionWay &way, int flag) { way.access_turn_classification = flag; })); [](ExtractionWay &way, int flag) { way.access_turn_classification = flag; }));
auto getTypedRefBySol = [](const sol::object &obj) -> ExtractionRelation::OsmIDTyped auto getTypedRefBySol = [](const sol::object &obj) -> ExtractionRelation::OsmIDTyped {
{
if (obj.is<osmium::Way>()) if (obj.is<osmium::Way>())
{ {
osmium::Way *way = obj.as<osmium::Way *>(); osmium::Way *way = obj.as<osmium::Way *>();
@ -460,19 +456,20 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"get_value_by_key", "get_value_by_key",
[](ExtractionRelation &rel, const char *key) -> const char * { return rel.GetAttr(key); }, [](ExtractionRelation &rel, const char *key) -> const char * { return rel.GetAttr(key); },
"get_role", "get_role",
[&getTypedRefBySol](ExtractionRelation &rel, const sol::object &obj) -> const char * [&getTypedRefBySol](ExtractionRelation &rel, const sol::object &obj) -> const char * {
{ return rel.GetRole(getTypedRefBySol(obj)); }); return rel.GetRole(getTypedRefBySol(obj));
});
context.state.new_usertype<ExtractionRelationContainer>( context.state.new_usertype<ExtractionRelationContainer>(
"ExtractionRelationContainer", "ExtractionRelationContainer",
"get_relations", "get_relations",
[&getTypedRefBySol](ExtractionRelationContainer &cont, const sol::object &obj) [&getTypedRefBySol](ExtractionRelationContainer &cont, const sol::object &obj)
-> const ExtractionRelationContainer::RelationIDList & -> const ExtractionRelationContainer::RelationIDList & {
{ return cont.GetRelations(getTypedRefBySol(obj)); }, return cont.GetRelations(getTypedRefBySol(obj));
},
"relation", "relation",
[](ExtractionRelationContainer &cont, [](ExtractionRelationContainer &cont, const ExtractionRelation::OsmIDTyped &rel_id)
const ExtractionRelation::OsmIDTyped &rel_id) -> const ExtractionRelation & -> const ExtractionRelation & { return cont.GetRelationData(rel_id); });
{ return cont.GetRelationData(rel_id); });
context.state.new_usertype<ExtractionSegment>("ExtractionSegment", context.state.new_usertype<ExtractionSegment>("ExtractionSegment",
"source", "source",
@ -488,12 +485,10 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
// Keep in mind .location is available only if .pbf is preprocessed to set the location with the // Keep in mind .location is available only if .pbf is preprocessed to set the location with the
// ref using osmium command "osmium add-locations-to-ways" // ref using osmium command "osmium add-locations-to-ways"
context.state.new_usertype<osmium::NodeRef>("NodeRef", context.state.new_usertype<osmium::NodeRef>(
"id", "NodeRef", "id", &osmium::NodeRef::ref, "location", [](const osmium::NodeRef &nref) {
&osmium::NodeRef::ref, return nref.location();
"location", });
[](const osmium::NodeRef &nref)
{ return nref.location(); });
context.state.new_usertype<InternalExtractorEdge>("EdgeSource", context.state.new_usertype<InternalExtractorEdge>("EdgeSource",
"source_coordinate", "source_coordinate",
@ -549,8 +544,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
util::Log() << "Using profile api version " << context.api_version; util::Log() << "Using profile api version " << context.api_version;
// version-dependent parts of the api // version-dependent parts of the api
auto initV2Context = [&]() auto initV2Context = [&]() {
{
// clear global not used in v2 // clear global not used in v2
context.state["properties"] = sol::nullopt; context.state["properties"] = sol::nullopt;
@ -641,31 +635,26 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
} }
}; };
auto initialize_V3_extraction_turn = [&]() auto initialize_V3_extraction_turn = [&]() {
{
context.state.new_usertype<ExtractionTurn>( context.state.new_usertype<ExtractionTurn>(
"ExtractionTurn", "ExtractionTurn",
"angle", "angle",
&ExtractionTurn::angle, &ExtractionTurn::angle,
"turn_type", "turn_type",
sol::property( sol::property([](const ExtractionTurn &turn) {
[](const ExtractionTurn &turn) if (turn.number_of_roads > 2 || turn.source_mode != turn.target_mode ||
{ turn.is_u_turn)
if (turn.number_of_roads > 2 || turn.source_mode != turn.target_mode || return osrm::guidance::TurnType::Turn;
turn.is_u_turn) else
return osrm::guidance::TurnType::Turn; return osrm::guidance::TurnType::NoTurn;
else }),
return osrm::guidance::TurnType::NoTurn;
}),
"direction_modifier", "direction_modifier",
sol::property( sol::property([](const ExtractionTurn &turn) {
[](const ExtractionTurn &turn) if (turn.is_u_turn)
{ return osrm::guidance::DirectionModifier::UTurn;
if (turn.is_u_turn) else
return osrm::guidance::DirectionModifier::UTurn; return osrm::guidance::DirectionModifier::Straight;
else }),
return osrm::guidance::DirectionModifier::Straight;
}),
"has_traffic_light", "has_traffic_light",
&ExtractionTurn::has_traffic_light, &ExtractionTurn::has_traffic_light,
"weight", "weight",