pass flags into process_segment (#6658)
* pass flags into process_segment --------- Co-authored-by: Michael Bell <michael@mjjbell.com>
This commit is contained in:
parent
8ef366e061
commit
7ebd21f39e
@ -5,6 +5,7 @@
|
||||
- ADDED: Add support for a default_radius flag. [#6575](https://github.com/Project-OSRM/osrm-backend/pull/6575)
|
||||
- ADDED: Add support for disabling feature datasets. [#6666](https://github.com/Project-OSRM/osrm-backend/pull/6666)
|
||||
- ADDED: Add support for opposite approach request parameter. [#6842](https://github.com/Project-OSRM/osrm-backend/pull/6842)
|
||||
- ADDED: Add support for accessing edge flags in `process_segment` [#6658](https://github.com/Project-OSRM/osrm-backend/pull/6658)
|
||||
- Build:
|
||||
- ADDED: Add CI job which builds OSRM with gcc 12. [#6455](https://github.com/Project-OSRM/osrm-backend/pull/6455)
|
||||
- CHANGED: Upgrade to clang-tidy 15. [#6439](https://github.com/Project-OSRM/osrm-backend/pull/6439)
|
||||
|
@ -154,3 +154,27 @@ Feature: osrm-extract lua ways:get_nodes()
|
||||
Then it should exit successfully
|
||||
And stdout should contain "node 42"
|
||||
And stdout should contain "way 42"
|
||||
|
||||
Scenario: osrm-extract flags accessible in process_segment function
|
||||
Given the profile file
|
||||
"""
|
||||
functions = require('testbot')
|
||||
|
||||
functions.process_segment = function (profile, segment)
|
||||
print('segment forward ' .. tostring(segment.flags.forward) .. ' backward ' .. tostring(segment.flags.backward))
|
||||
end
|
||||
|
||||
return functions
|
||||
"""
|
||||
|
||||
And the node map
|
||||
"""
|
||||
a b
|
||||
"""
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| ab | yes |
|
||||
And the data has been saved to disk
|
||||
When I run "osrm-extract --profile {profile_file} {osm_file}"
|
||||
Then it should exit successfully
|
||||
And stdout should contain "segment forward true backward false"
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OSRM_EXTRACTION_SEGMENT_HPP
|
||||
#define OSRM_EXTRACTION_SEGMENT_HPP
|
||||
|
||||
#include <extractor/node_based_edge.hpp>
|
||||
#include <util/coordinate.hpp>
|
||||
|
||||
namespace osrm::extractor
|
||||
@ -12,9 +13,10 @@ struct ExtractionSegment
|
||||
const osrm::util::Coordinate target_,
|
||||
double distance_,
|
||||
double weight_,
|
||||
double duration_)
|
||||
double duration_,
|
||||
const NodeBasedEdgeClassification flags_)
|
||||
: source(source_), target(target_), distance(distance_), weight(weight_),
|
||||
duration(duration_)
|
||||
duration(duration_), flags(flags_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -23,6 +25,7 @@ struct ExtractionSegment
|
||||
const double distance;
|
||||
double weight;
|
||||
double duration;
|
||||
const NodeBasedEdgeClassification flags;
|
||||
};
|
||||
} // namespace osrm::extractor
|
||||
|
||||
|
@ -706,7 +706,12 @@ 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;
|
||||
|
@ -471,6 +471,36 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
||||
[](ExtractionRelationContainer &cont, const ExtractionRelation::OsmIDTyped &rel_id)
|
||||
-> const ExtractionRelation & { return cont.GetRelationData(rel_id); });
|
||||
|
||||
context.state.new_usertype<NodeBasedEdgeClassification>(
|
||||
"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>("ExtractionSegment",
|
||||
"source",
|
||||
&ExtractionSegment::source,
|
||||
@ -481,7 +511,9 @@ 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"
|
||||
|
Loading…
Reference in New Issue
Block a user