From 00083735e453b8c01ee15b06d5df977e7161830c Mon Sep 17 00:00:00 2001 From: Matt Bhagat-Conway Date: Tue, 18 Jul 2023 16:54:44 -0700 Subject: [PATCH] pass flags into process_segment --- include/extractor/extraction_segment.hpp | 6 +++-- src/extractor/extraction_containers.cpp | 2 +- src/extractor/scripting_environment_lua.cpp | 29 ++++++++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/include/extractor/extraction_segment.hpp b/include/extractor/extraction_segment.hpp index f6bda5e48c7..388ca7a24ee 100644 --- a/include/extractor/extraction_segment.hpp +++ b/include/extractor/extraction_segment.hpp @@ -12,9 +12,10 @@ struct ExtractionSegment const osrm::util::Coordinate target_, double distance_, double weight_, - double duration_) + double duration_, + const osrm::extractor::NodeBasedEdgeClassification flags_) : source(source_), target(target_), distance(distance_), weight(weight_), - duration(duration_) + duration(duration_), flags(flags_) { } @@ -23,6 +24,7 @@ struct ExtractionSegment const double distance; double weight; double duration; + const osrm::extractor::NodeBasedEdgeClassification flags; }; } // namespace osrm::extractor diff --git a/src/extractor/extraction_containers.cpp b/src/extractor/extraction_containers.cpp index d75122d48fe..c1800488891 100644 --- a/src/extractor/extraction_containers.cpp +++ b/src/extractor/extraction_containers.cpp @@ -706,7 +706,7 @@ void ExtractionContainers::PrepareEdges(ScriptingEnvironment &scripting_environm const auto accurate_distance = util::coordinate_calculation::greatCircleDistance(source_coord, target_coord); - ExtractionSegment segment(source_coord, target_coord, distance, weight, duration); + ExtractionSegment segment(source_coord, target_coord, distance, weight, duration, edge_iterator->result.flags); scripting_environment.ProcessSegment(segment); auto &edge = edge_iterator->result; diff --git a/src/extractor/scripting_environment_lua.cpp b/src/extractor/scripting_environment_lua.cpp index 9576cc18bb1..ddbea313ddb 100644 --- a/src/extractor/scripting_environment_lua.cpp +++ b/src/extractor/scripting_environment_lua.cpp @@ -471,6 +471,30 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context) [](ExtractionRelationContainer &cont, const ExtractionRelation::OsmIDTyped &rel_id) -> const ExtractionRelation & { return cont.GetRelationData(rel_id); }); + context.state.new_usertype("NodeBasedEdgeClassification", + "forward", + // can't just do &NodeBasedEdgeClassification::forward with bitfields + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.forward; }), + "backward", + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.backward; }), + "is_split", + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.is_split; }), + "roundabout", + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.roundabout; }), + "circular", + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.circular; }), + "startpoint", + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.startpoint; }), + "restricted", + sol::property([](NodeBasedEdgeClassification &c) -> bool { return c.restricted; }), + "road_classification", + sol::property([](NodeBasedEdgeClassification &c) -> RoadClassification { return c.road_classification; }), + "highway_turn_classification", + sol::property([](NodeBasedEdgeClassification &c) -> uint8_t { return c.highway_turn_classification; }), + "access_turn_classification", + sol::property([](NodeBasedEdgeClassification &c) -> uint8_t { return c.access_turn_classification; }) + ); + context.state.new_usertype("ExtractionSegment", "source", &ExtractionSegment::source, @@ -481,7 +505,10 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context) "weight", &ExtractionSegment::weight, "duration", - &ExtractionSegment::duration); + &ExtractionSegment::duration, + "flags", + &ExtractionSegment::flags); + // 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"