Skip to content

Commit

Permalink
small nitpicks and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chaupow committed Jan 17, 2018
1 parent 7e9cd14 commit 8778c86
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ end
function process_turn(profile, turn) {
if turn.source_highway_turn_classification == 2 and turn.target_highway_turn_classification == 2 then
turn.weight = 10
else if turn.source_highway_turn_classification == 1 and turn.target_highway_turn_classification == 1 then
end
if turn.source_highway_turn_classification == 1 and turn.target_highway_turn_classification == 1 then
turn.weight = 5
end
}
Expand Down
1 change: 1 addition & 0 deletions features/support/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = function () {
.defer(rimraf, this.scenarioLogFile)
.awaitAll(callback);
// Question @review is this line nice to have here (commented, but ready to use and uncomment if needed?)
// i think this is super useful and would love to have it here
// console.log(" Writing logging output to " + this.scenarioLogFile)
});

Expand Down
6 changes: 0 additions & 6 deletions include/extractor/extraction_turn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct ExtractionTurn
int number_of_roads,
bool is_u_turn,
bool has_traffic_light,
// bool is_stop, bool is_give_way,
bool is_left_hand_driving,
bool source_restricted,
TravelMode source_mode,
Expand Down Expand Up @@ -93,16 +92,11 @@ struct ExtractionTurn
{
BOOST_ASSERT_MSG(!is_u_turn || roads_on_the_left.size() == 0,
"there cannot be roads on the left when there is a u turn");
BOOST_ASSERT_MSG(roads_on_the_right.size() + roads_on_the_left.size() + is_u_turn + 2 ==
number_of_roads,
"number of roads at intersection do not match");
}
const double angle;
const int number_of_roads;
const bool is_u_turn;
const bool has_traffic_light;
// const bool is_stop;
// const bool is_give_way;
const bool is_left_hand_driving;

// source info
Expand Down
4 changes: 2 additions & 2 deletions include/extractor/extraction_way.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ struct ExtractionWay
bool : 2;

// user classifications for turn penalties
std::uint8_t highway_turn_classification; // @CHAUTODO memory? limit to 3 bits? // 8
std::uint8_t access_turn_classification; // 3 are enough
std::uint8_t highway_turn_classification : 4;
std::uint8_t access_turn_classification : 4;
};
}
}
Expand Down
6 changes: 3 additions & 3 deletions include/extractor/node_based_edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ struct NodeBasedEdgeClassification
std::uint8_t startpoint : 1; // 1
std::uint8_t restricted : 1; // 1
guidance::RoadClassification road_classification; // 16 2
std::uint8_t highway_turn_classification; // @CHAUTODO memory? limit to 3 bits? // 8
std::uint8_t access_turn_classification; // 3 are enough // 8
std::uint8_t speed; // one bit could be saved here too I guess, so 7 // 8
std::uint8_t highway_turn_classification : 4; // 4
std::uint8_t access_turn_classification : 4; // 4
std::uint8_t speed; // 8

NodeBasedEdgeClassification();

Expand Down
2 changes: 1 addition & 1 deletion include/partition/multi_level_partition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ template <storage::Ownership Ownership> class MultiLevelPartitionImpl final
auto offsets = MakeLevelOffsets(lidx_to_num_cells);
auto masks = MakeLevelMasks(offsets, num_level);
auto bits = MakeBitToLevel(offsets, num_level);
return std::make_unique<LevelData>(LevelData{num_level, offsets, masks, bits, {0}});
return std::make_unique<LevelData>(LevelData{num_level, offsets, masks, bits, {{0}}});
}

inline std::size_t LevelIDToIndex(LevelID l) const { return l - 1; }
Expand Down
7 changes: 7 additions & 0 deletions profiles/lib/way_handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ function WayHandlers.way_classification_for_turn(profile,way,result,data)
local highway = way:get_value_by_key("highway")
local access = way:get_value_by_key("access")

if profile.highway_turn_classification[highway] then
assert(profile.highway_turn_classification[highway] < 16, "highway_turn_classification must be smaller than 16")
end
if profile.access_turn_classification[highway] then
assert(profile.access_turn_classification[highway] < 16, "access_turn_classification must be smaller than 16")
end

if highway and profile.highway_turn_classification[highway] then
result.highway_turn_classification = profile.highway_turn_classification[highway]
end
Expand Down
11 changes: 9 additions & 2 deletions src/extractor/edge_based_graph_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,14 +599,15 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(

// compute weight and duration penalties
auto is_traffic_light = m_traffic_lights.count(intersection_node);

std::vector<ExtractionTurnLeg> road_legs_on_the_right;
std::vector<ExtractionTurnLeg> road_legs_on_the_left;

auto turn_iter =
std::find_if(intersection.begin(), intersection.end(), [&turn](const auto &road) {
return road.eid == turn.eid;
});

// if the turn is a u turn, store all information in road_legs_on_the_right
if (turn_iter == intersection.begin())
{
for (auto connected_edge = intersection.begin() + 1;
Expand All @@ -627,6 +628,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
connected_edge->entry_allowed);
}
}
// otherwise split roads into the right or left side of the turn and store info
else
{
for (auto connected_edge = intersection.begin() + 1; connected_edge < turn_iter;
Expand Down Expand Up @@ -662,13 +664,16 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
connected_edge->entry_allowed);
}
}

ExtractionTurn extracted_turn(
// general info
turn.angle,
m_node_based_graph.GetOutDegree(intersection_node),
intersection.size(),
turn.instruction.IsUTurn(),
is_traffic_light,
m_edge_based_node_container.GetAnnotation(edge_data1.annotation_data)
.is_left_hand_driving,
// source info
edge_data1.flags.restricted,
m_edge_based_node_container.GetAnnotation(edge_data1.annotation_data).travel_mode,
edge_data1.flags.road_classification.IsMotorwayClass(),
Expand All @@ -677,6 +682,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
edge_data1.flags.highway_turn_classification,
edge_data1.flags.access_turn_classification,
edge_data1.flags.speed,
// target info
edge_data2.flags.restricted,
m_edge_based_node_container.GetAnnotation(edge_data2.annotation_data).travel_mode,
edge_data2.flags.road_classification.IsMotorwayClass(),
Expand All @@ -685,6 +691,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
edge_data2.flags.highway_turn_classification,
edge_data2.flags.access_turn_classification,
edge_data2.flags.speed,
// connected roads
road_legs_on_the_right,
road_legs_on_the_left);

Expand Down
2 changes: 0 additions & 2 deletions src/extractor/extractor_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
parsed_way.is_startpoint,
parsed_way.forward_restricted,
road_classification,
// @CHAUTODO
parsed_way.highway_turn_classification,
parsed_way.access_turn_classification,
speed}};
Expand Down Expand Up @@ -466,7 +465,6 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
parsed_way.is_startpoint,
parsed_way.backward_restricted,
road_classification,
// @CHAUTODO
parsed_way.highway_turn_classification,
parsed_way.access_turn_classification,
speed}};
Expand Down
6 changes: 4 additions & 2 deletions src/extractor/scripting_environment_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,11 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
sol::property([](const ExtractionWay &way) { return way.is_left_hand_driving; },
[](ExtractionWay &way, bool flag) { way.is_left_hand_driving = flag; }),
"highway_turn_classification",
&ExtractionWay::highway_turn_classification,
sol::property([](const ExtractionWay &way) { return way.highway_turn_classification; },
[](ExtractionWay &way, int flag) { way.highway_turn_classification = flag; }),
"access_turn_classification",
&ExtractionWay::access_turn_classification);
sol::property([](const ExtractionWay &way) { return way.access_turn_classification; },
[](ExtractionWay &way, int flag) { way.access_turn_classification = flag; }));

auto getTypedRefBySol = [](const sol::object &obj) -> ExtractionRelation::OsmIDTyped {
if (obj.is<osmium::Way>())
Expand Down

0 comments on commit 8778c86

Please sign in to comment.