Skip to content

Commit

Permalink
Parses and attaches Priority Road flag to node based edges
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-j-h committed Oct 14, 2016
1 parent 68eef09 commit 8efba17
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 94 deletions.
38 changes: 6 additions & 32 deletions include/extractor/extraction_node.hpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
#ifndef EXTRACTION_NODE_HPP
#define EXTRACTION_NODE_HPP

#include "extractor/road_signs.hpp"

#include <cstdint>

namespace osrm
{
namespace extractor
{

// Stop Signs tagged on nodes can be present or not. In addition Stop Signs have
// an optional way direction they apply to. If the direction is unknown from the
// data we have to compute by checking the distance to the next intersection.
//
// Impl. detail: namespace + enum instead of enum class to make Luabind happy
namespace StopSign
{
enum State : std::uint8_t
{
No = 1 << 0,
YesUnknownDirection = 1 << 1,
YesForward = 1 << 2,
YesBackward = 1 << 3,
};
}

// Give Way is the complement to priority roads. Tagging is the same as Stop Signs.
// See explanation above.
namespace GiveWay
{
enum State : std::uint8_t
{
No = 1 << 0,
YesUnknownDirection = 1 << 1,
YesForward = 1 << 2,
YesBackward = 1 << 3,
};
}

struct ExtractionNode
{
ExtractionNode()
: traffic_lights(false), barrier(false), stop_sign(StopSign::No), give_way(GiveWay::No)
: traffic_lights(false), barrier(false), stop_sign(StopSign::No),
give_way_sign(GiveWaySign::No)
{
}

Expand All @@ -49,14 +23,14 @@ struct ExtractionNode
traffic_lights = false;
barrier = false;
stop_sign = StopSign::No;
give_way = GiveWay::No;
give_way_sign = GiveWaySign::No;
}

bool traffic_lights;
bool barrier;

StopSign::State stop_sign;
GiveWay::State give_way;
GiveWaySign::State give_way_sign;
};
}
}
Expand Down
4 changes: 4 additions & 0 deletions include/extractor/extraction_way.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct ExtractionWay
duration = -1;
roundabout = false;
is_startpoint = true;
is_priority_road_forward = false;
is_priority_road_backward = false;
is_access_restricted = false;
name.clear();
ref.clear();
Expand Down Expand Up @@ -62,6 +64,8 @@ struct ExtractionWay
bool roundabout;
bool is_access_restricted;
bool is_startpoint;
bool is_priority_road_forward;
bool is_priority_road_backward;
TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4;
guidance::RoadClassification road_classification;
Expand Down
10 changes: 10 additions & 0 deletions include/extractor/internal_extractor_edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct InternalExtractorEdge
false,
false,
true,
false, // road_priority_forward
false, // road_priority_backward
TRAVEL_MODE_INACCESSIBLE,
false,
guidance::TurnLaneType::empty,
Expand All @@ -64,6 +66,8 @@ struct InternalExtractorEdge
bool roundabout,
bool access_restricted,
bool startpoint,
bool road_priority_forward,
bool road_priority_backward,
TravelMode travel_mode,
bool is_split,
LaneDescriptionID lane_description,
Expand All @@ -77,6 +81,8 @@ struct InternalExtractorEdge
roundabout,
access_restricted,
startpoint,
road_priority_forward,
road_priority_backward,
travel_mode,
is_split,
lane_description,
Expand Down Expand Up @@ -104,6 +110,8 @@ struct InternalExtractorEdge
false,
false,
true,
false, // road_priority_forward
false, // road_priority_backward
TRAVEL_MODE_INACCESSIBLE,
false,
INVALID_LANE_DESCRIPTIONID,
Expand All @@ -120,6 +128,8 @@ struct InternalExtractorEdge
false,
false,
true,
false, // road_priority_forward
false, // road_priority_backward
TRAVEL_MODE_INACCESSIBLE,
false,
INVALID_LANE_DESCRIPTIONID,
Expand Down
18 changes: 16 additions & 2 deletions include/extractor/node_based_edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct NodeBasedEdge
bool roundabout,
bool access_restricted,
bool startpoint,
bool priority_road_forward,
bool priority_road_backward,
TravelMode travel_mode,
bool is_split,
const LaneDescriptionID lane_description_id,
Expand All @@ -40,6 +42,8 @@ struct NodeBasedEdge
bool roundabout : 1;
bool access_restricted : 1;
bool startpoint : 1;
bool priority_road_forward : 1;
bool priority_road_backward : 1;
bool is_split : 1;
TravelMode travel_mode : 4;
LaneDescriptionID lane_description_id;
Expand All @@ -57,6 +61,8 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
bool roundabout,
bool access_restricted,
bool startpoint,
bool priority_road_forward,
bool priority_road_backward,
TravelMode travel_mode,
bool is_split,
const LaneDescriptionID lane_description_id,
Expand All @@ -71,7 +77,8 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
inline NodeBasedEdge::NodeBasedEdge()
: source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false),
backward(false), roundabout(false), access_restricted(false), startpoint(true),
is_split(false), travel_mode(false), lane_description_id(INVALID_LANE_DESCRIPTIONID)
priority_road_forward(false), priority_road_backward(false), is_split(false),
travel_mode(false), lane_description_id(INVALID_LANE_DESCRIPTIONID)
{
}

Expand All @@ -84,13 +91,16 @@ inline NodeBasedEdge::NodeBasedEdge(NodeID source,
bool roundabout,
bool access_restricted,
bool startpoint,
bool priority_road_forward,
bool priority_road_backward,
TravelMode travel_mode,
bool is_split,
const LaneDescriptionID lane_description_id,
guidance::RoadClassification road_classification)
: source(source), target(target), name_id(name_id), weight(weight), forward(forward),
backward(backward), roundabout(roundabout), access_restricted(access_restricted),
startpoint(startpoint), is_split(is_split), travel_mode(travel_mode),
startpoint(startpoint), priority_road_forward(priority_road_forward),
priority_road_backward(priority_road_backward), is_split(is_split), travel_mode(travel_mode),
lane_description_id(lane_description_id), road_classification(std::move(road_classification))
{
}
Expand Down Expand Up @@ -121,6 +131,8 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(OSMNodeID source,
bool roundabout,
bool access_restricted,
bool startpoint,
bool priority_road_forward,
bool priority_road_backward,
TravelMode travel_mode,
bool is_split,
const LaneDescriptionID lane_description_id,
Expand All @@ -134,6 +146,8 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(OSMNodeID source,
roundabout,
access_restricted,
startpoint,
priority_road_forward,
priority_road_backward,
travel_mode,
is_split,
lane_description_id,
Expand Down
43 changes: 43 additions & 0 deletions include/extractor/road_signs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef OSRM_PRIORITY_ROADS_HPP
#define OSRM_PRIORITY_ROADS_HPP

#include <cstdint>

namespace osrm
{
namespace extractor
{
// Impl. detail: namespace + enum instead of enum class to make Luabind happy
// TODO: make type safe enum classes as soon as we can bind them to Lua.

// Stop Signs tagged on nodes can be present or not. In addition Stop Signs have
// an optional way direction they apply to. If the direction is unknown from the
// data we have to compute by checking the distance to the next intersection.
namespace StopSign
{
enum State : std::uint8_t
{
No = 1 << 0,
YesUnknownDirection = 1 << 1,
YesForward = 1 << 2,
YesBackward = 1 << 3,
};
}

// Give Way is the complement to priority roads. Tagging is the same as Stop Signs.
// See explanation above.
namespace GiveWaySign
{
enum State : std::uint8_t
{
No = 1 << 0,
YesUnknownDirection = 1 << 1,
YesForward = 1 << 2,
YesBackward = 1 << 3,
};
}

}
}

#endif // EXTRACTION_NODE_HPP
15 changes: 13 additions & 2 deletions include/util/node_based_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ struct NodeBasedEdgeData
bool reversed,
bool roundabout,
bool startpoint,
bool priority_road_forward,
bool priority_road_backward,
extractor::TravelMode travel_mode,
const LaneDescriptionID lane_description_id)
: distance(distance), edge_id(edge_id), name_id(name_id),
access_restricted(access_restricted), reversed(reversed), roundabout(roundabout),
startpoint(startpoint), travel_mode(travel_mode), lane_description_id(lane_description_id)
startpoint(startpoint), priority_road_forward(priority_road_forward),
priority_road_backward(priority_road_backward), travel_mode(travel_mode),
lane_description_id(lane_description_id)
{
}

Expand All @@ -47,14 +51,19 @@ struct NodeBasedEdgeData
bool reversed : 1;
bool roundabout : 1;
bool startpoint : 1;
bool priority_road_forward : 1;
bool priority_road_backward : 1;
extractor::TravelMode travel_mode : 4;
LaneDescriptionID lane_description_id;
extractor::guidance::RoadClassification road_classification;

bool IsCompatibleTo(const NodeBasedEdgeData &other) const
{
return (reversed == other.reversed) && (roundabout == other.roundabout) &&
(startpoint == other.startpoint) && (access_restricted == other.access_restricted) &&
(startpoint == other.startpoint) &&
(priority_road_forward == other.priority_road_forward) &&
(priority_road_backward == other.priority_road_backward) &&
(access_restricted == other.access_restricted) &&
(travel_mode == other.travel_mode) &&
(road_classification == other.road_classification);
}
Expand Down Expand Up @@ -86,6 +95,8 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
output_edge.data.access_restricted = input_edge.access_restricted;
output_edge.data.travel_mode = input_edge.travel_mode;
output_edge.data.startpoint = input_edge.startpoint;
output_edge.data.priority_road_forward = input_edge.priority_road_forward;
output_edge.data.priority_road_backward = input_edge.priority_road_backward;
output_edge.data.road_classification = input_edge.road_classification;
output_edge.data.lane_description_id = input_edge.lane_description_id;
});
Expand Down
Loading

0 comments on commit 8efba17

Please sign in to comment.