Making the turn function more flexible (#4789)

* set and store highway and access classification for the turn function
* expose highway turn classification and access turn classification and speed to the lua profile turn function
* expose whether connection road at turn is incoming or outgoing
* add lua tests for exposed information to turn function
* update docs about attributes in process_turn
* add turn_classification info to docs
* adding warning if uturn and intersection dont match
* handle u turns that do not turn into intersection[0]
* split OSM link generation in an accessible coordinate function
This commit is contained in:
Huyen Chau Nguyen
2018-01-24 15:39:55 -05:00
committed by GitHub
parent 13bb997525
commit 61e06fcaba
17 changed files with 719 additions and 146 deletions
+91 -11
View File
@@ -12,35 +12,115 @@ namespace osrm
namespace extractor
{
struct ExtractionTurnLeg
{
ExtractionTurnLeg(bool is_restricted,
bool is_motorway,
bool is_link,
int number_of_lanes,
int highway_turn_classification,
int access_turn_classification,
int speed,
bool is_incoming,
bool is_outgoing)
: is_restricted(is_restricted), is_motorway(is_motorway), is_link(is_link),
number_of_lanes(number_of_lanes),
highway_turn_classification(highway_turn_classification),
access_turn_classification(access_turn_classification), speed(speed),
is_incoming(is_incoming), is_outgoing(is_outgoing)
{
}
const bool is_restricted;
const bool is_motorway;
const bool is_link;
const int number_of_lanes;
const int highway_turn_classification;
const int access_turn_classification;
const int speed;
const bool is_incoming;
const bool is_outgoing;
};
struct ExtractionTurn
{
ExtractionTurn(double angle,
int number_of_roads,
bool is_u_turn,
bool has_traffic_light,
bool source_restricted,
bool target_restricted,
bool is_left_hand_driving,
bool source_restricted,
TravelMode source_mode,
TravelMode target_mode)
bool source_is_motorway,
bool source_is_link,
int source_number_of_lanes,
int source_highway_turn_classification,
int source_access_turn_classification,
int source_speed,
bool target_restricted,
TravelMode target_mode,
bool target_is_motorway,
bool target_is_link,
int target_number_of_lanes,
int target_highway_turn_classification,
int target_access_turn_classification,
int target_speed,
const std::vector<ExtractionTurnLeg> &roads_on_the_right,
const std::vector<ExtractionTurnLeg> &roads_on_the_left)
: angle(180. - angle), number_of_roads(number_of_roads), is_u_turn(is_u_turn),
has_traffic_light(has_traffic_light), source_restricted(source_restricted),
target_restricted(target_restricted), is_left_hand_driving(is_left_hand_driving),
weight(0.), duration(0.), source_mode(source_mode), target_mode(target_mode)
has_traffic_light(has_traffic_light), is_left_hand_driving(is_left_hand_driving),
source_restricted(source_restricted), source_mode(source_mode),
source_is_motorway(source_is_motorway), source_is_link(source_is_link),
source_number_of_lanes(source_number_of_lanes),
source_highway_turn_classification(source_highway_turn_classification),
source_access_turn_classification(source_access_turn_classification),
source_speed(source_speed),
target_restricted(target_restricted), target_mode(target_mode),
target_is_motorway(target_is_motorway), target_is_link(target_is_link),
target_number_of_lanes(target_number_of_lanes),
target_highway_turn_classification(target_highway_turn_classification),
target_access_turn_classification(target_access_turn_classification),
target_speed(target_speed),
roads_on_the_right(roads_on_the_right), roads_on_the_left(roads_on_the_left), weight(0.),
duration(0.)
{
}
const double angle;
const int number_of_roads;
const bool is_u_turn;
const bool has_traffic_light;
const bool source_restricted;
const bool target_restricted;
const bool is_left_hand_driving;
// source info
const bool source_restricted;
const TravelMode source_mode;
const bool source_is_motorway;
const bool source_is_link;
const int source_number_of_lanes;
const int source_highway_turn_classification;
const int source_access_turn_classification;
const int source_speed;
// target info
const bool target_restricted;
const TravelMode target_mode;
const bool target_is_motorway;
const bool target_is_link;
const int target_number_of_lanes;
const int target_highway_turn_classification;
const int target_access_turn_classification;
const int target_speed;
const std::vector<ExtractionTurnLeg> roads_on_the_right;
const std::vector<ExtractionTurnLeg> roads_on_the_left;
double weight;
double duration;
const TravelMode source_mode;
const TravelMode target_mode;
};
}
}
+6
View File
@@ -63,6 +63,8 @@ struct ExtractionWay
forward_restricted = false;
backward_restricted = false;
is_left_hand_driving = false;
highway_turn_classification = 0;
access_turn_classification = 0;
}
// wrappers to allow assigning nil (nullptr) to string values
@@ -123,6 +125,10 @@ struct ExtractionWay
bool backward_restricted : 1;
bool is_left_hand_driving : 1;
bool : 2;
// user classifications for turn penalties
std::uint8_t highway_turn_classification : 4;
std::uint8_t access_turn_classification : 4;
};
}
}
+8 -2
View File
@@ -27,6 +27,8 @@ 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 : 4; // 4
std::uint8_t access_turn_classification : 4; // 4
NodeBasedEdgeClassification();
@@ -37,10 +39,14 @@ struct NodeBasedEdgeClassification
const bool circular,
const bool startpoint,
const bool restricted,
guidance::RoadClassification road_classification)
guidance::RoadClassification road_classification,
const std::uint8_t highway_turn_classification,
const std::uint8_t access_turn_classification)
: forward(forward), backward(backward), is_split(is_split), roundabout(roundabout),
circular(circular), startpoint(startpoint), restricted(restricted),
road_classification(road_classification)
road_classification(road_classification),
highway_turn_classification(highway_turn_classification),
access_turn_classification(access_turn_classification)
{
}
+1 -1
View File
@@ -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; }
+1 -3
View File
@@ -20,9 +20,7 @@
if (!static_cast<bool>(cond)) \
{ \
::osrm::util::FloatCoordinate c_(loc); \
std::cerr << "[Location] " \
<< "http://www.openstreetmap.org/?mlat=" << c_.lat << "&mlon=" << c_.lon \
<< "#map=19/" << c_.lat << "/" << c_.lon << '\n'; \
std::cerr << "[Location] " << c_.toOSMLink() << '\n'; \
} \
BOOST_ASSERT_MSG(cond, msg); \
} while (0)
+18
View File
@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstddef>
#include <iosfwd> //for std::ostream
#include <sstream>
#include <string>
#include <type_traits>
@@ -216,6 +217,15 @@ struct Coordinate
friend bool operator==(const Coordinate lhs, const Coordinate rhs);
friend bool operator!=(const Coordinate lhs, const Coordinate rhs);
friend std::ostream &operator<<(std::ostream &out, const Coordinate coordinate);
std::string toOSMLink() const
{
std::stringstream link;
link << "http://www.openstreetmap.org/?mlat=" << toFloating(lat)
<< "&mlon=" << toFloating(lon) << "#map=19/" << toFloating(lat) << "/"
<< toFloating(lon);
return link.str();
}
};
/**
@@ -257,6 +267,14 @@ struct FloatCoordinate
friend bool operator==(const FloatCoordinate lhs, const FloatCoordinate rhs);
friend bool operator!=(const FloatCoordinate lhs, const FloatCoordinate rhs);
friend std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate);
std::string toOSMLink() const
{
std::stringstream link;
link << "http://www.openstreetmap.org/?mlat=" << lat << "&mlon=" << lon << "#map=19/" << lat
<< "/" << lon;
return link.str();
}
};
bool operator==(const Coordinate lhs, const Coordinate rhs);