/
srv
/
osrm
/
osrm-backend
/
include
/
extractor
/
/srv/osrm/osrm-backend/include/extractor
mkdir
upload
Name
Size
Mode
Actions
intersection/
-
0755
rm
class_data.hpp
981
0644
edit
dl
rm
compressed_edge_container.hpp
3336
0644
edit
dl
rm
compressed_node_based_graph_edge.hpp
418
0644
edit
dl
rm
conditional_turn_penalty.hpp
589
0644
edit
dl
rm
datasources.hpp
1207
0644
edit
dl
rm
edge_based_edge.hpp
3467
0644
edit
dl
rm
edge_based_graph_factory.hpp
7787
0644
edit
dl
rm
edge_based_node.hpp
383
0644
edit
dl
rm
edge_based_node_segment.hpp
2050
0644
edit
dl
rm
extraction_containers.hpp
3679
0644
edit
dl
rm
extraction_helper_functions.hpp
4827
0644
edit
dl
rm
extraction_node.hpp
459
0644
edit
dl
rm
extraction_relation.hpp
5949
0644
edit
dl
rm
extraction_segment.hpp
715
0644
edit
dl
rm
extraction_turn.hpp
4983
0644
edit
dl
rm
extraction_way.hpp
4268
0644
edit
dl
rm
extractor.hpp
5267
0644
edit
dl
rm
extractor_callbacks.hpp
3249
0644
edit
dl
rm
extractor_config.hpp
3040
0644
edit
dl
rm
files.hpp
24372
0644
edit
dl
rm
graph_compressor.hpp
1271
0644
edit
dl
rm
internal_extractor_edge.hpp
2642
0644
edit
dl
rm
intersection_bearings_container.hpp
4487
0644
edit
dl
rm
location_dependent_data.hpp
1797
0644
edit
dl
rm
maneuver_override.hpp
5456
0644
edit
dl
rm
maneuver_override_relation_parser.hpp
1785
0644
edit
dl
rm
name_table.hpp
3596
0644
edit
dl
rm
nbg_to_ebg.hpp
450
0644
edit
dl
rm
nodes_of_way.hpp
1411
0644
edit
dl
rm
node_based_edge.hpp
8024
0644
edit
dl
rm
node_based_graph_factory.hpp
5155
0644
edit
dl
rm
node_data_container.hpp
4558
0644
edit
dl
rm
node_restriction_map.hpp
2292
0644
edit
dl
rm
packed_osm_ids.hpp
520
0644
edit
dl
rm
profile_properties.hpp
5029
0644
edit
dl
rm
query_node.hpp
1411
0644
edit
dl
rm
raster_source.hpp
5002
0644
edit
dl
rm
restriction.hpp
1750
0644
edit
dl
rm
restriction_graph.hpp
4500
0644
edit
dl
rm
restriction_parser.hpp
1768
0644
edit
dl
rm
road_classification.hpp
8390
0644
edit
dl
rm
scripting_environment.hpp
2426
0644
edit
dl
rm
scripting_environment_lua.hpp
4253
0644
edit
dl
rm
segment_data_container.hpp
8032
0644
edit
dl
rm
serialization.hpp
8834
0644
edit
dl
rm
suffix_table.hpp
1407
0644
edit
dl
rm
traffic_lights.hpp
514
0644
edit
dl
rm
traffic_signals.hpp
656
0644
edit
dl
rm
travel_mode.hpp
3666
0644
edit
dl
rm
turn_lane_types.hpp
3754
0644
edit
dl
rm
turn_path.hpp
7483
0644
edit
dl
rm
turn_path_compressor.hpp
2220
0644
edit
dl
rm
turn_path_filter.hpp
669
0644
edit
dl
rm
way_restriction_map.hpp
3114
0644
edit
dl
rm
Edit:
/srv/osrm/osrm-backend/include/extractor/road_classification.hpp
(8390B)
#ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_ #define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_ #include "extractor/intersection/constants.hpp" #include <algorithm> #include <boost/assert.hpp> #include <cmath> #include <cstdint> #include <cstdlib> #include <string> namespace osrm::extractor { // Priorities are used to distinguish between how likely a turn is in comparison to a different // road. The priorities here are used to distinguish between obvious turns (e.g. following a primary // road next to a residential one is obvious). The decision what is obvious is described in the // guidance constants. namespace RoadPriorityClass { using Enum = std::uint8_t; // Top priority Road const constexpr Enum MOTORWAY = 0; const constexpr Enum MOTORWAY_LINK = 1; // Second highest priority const constexpr Enum TRUNK = 2; const constexpr Enum TRUNK_LINK = 3; // Main roads const constexpr Enum PRIMARY = 4; const constexpr Enum PRIMARY_LINK = 5; const constexpr Enum SECONDARY = 6; const constexpr Enum SECONDARY_LINK = 7; const constexpr Enum TERTIARY = 8; const constexpr Enum TERTIARY_LINK = 9; // Residential Categories const constexpr Enum MAIN_RESIDENTIAL = 10; const constexpr Enum SIDE_RESIDENTIAL = 11; const constexpr Enum ALLEY = 12; const constexpr Enum PARKING = 13; // Link Category const constexpr Enum LINK_ROAD = 14; const constexpr Enum UNCLASSIFIED = 15; // Bike Accessible const constexpr Enum BIKE_PATH = 16; // Walk Accessible const constexpr Enum FOOT_PATH = 18; // Link types are usually not considered in forks, unless amongst each other. // a road simply offered for connectivity. Will be ignored in forks/other decisions. Always // considered non-obvious to continue on const constexpr Enum CONNECTIVITY = 31; } // namespace RoadPriorityClass #pragma pack(push, 1) class RoadClassification { // a class that behaves like a motorway (separated directions) std::uint8_t motorway_class : 1; // all types of link classes std::uint8_t link_class : 1; // a low priority class is a pure connectivity way. It can be ignored in multiple decisions // (e.g. fork on a primary vs service will not happen) std::uint8_t may_be_ignored : 1; // the road priority is used as an indicator for forks. If the roads are of similar priority // (difference <=1), we can see the road as a fork. Else one of the road classes is seen as // obvious choice RoadPriorityClass::Enum road_priority_class : 5; // the number of lanes in the road std::uint8_t number_of_lanes; public: // default construction RoadClassification() : motorway_class(0), link_class(0), may_be_ignored(0), road_priority_class(RoadPriorityClass::CONNECTIVITY), number_of_lanes(0) { } RoadClassification(bool motorway_class, bool link_class, bool may_be_ignored, RoadPriorityClass::Enum road_priority_class, std::uint8_t number_of_lanes) : motorway_class(motorway_class), link_class(link_class), may_be_ignored(may_be_ignored), road_priority_class(road_priority_class), number_of_lanes(number_of_lanes) { } bool IsMotorwayClass() const { return (0 != motorway_class) && (0 == link_class); } void SetMotorwayFlag(const bool new_value) { motorway_class = new_value; } bool IsRampClass() const { return (0 != motorway_class) && (0 != link_class); } bool IsLinkClass() const { return (0 != link_class); } void SetLinkClass(const bool new_value) { link_class = new_value; } bool IsLowPriorityRoadClass() const { return (0 != may_be_ignored); } void SetLowPriorityFlag(const bool new_value) { may_be_ignored = new_value; } std::uint8_t GetNumberOfLanes() const { return number_of_lanes; } void SetNumberOfLanes(const std::uint8_t new_value) { number_of_lanes = new_value; } std::uint32_t GetPriority() const { return static_cast<std::uint32_t>(road_priority_class); } RoadPriorityClass::Enum GetClass() const { return road_priority_class; } void SetClass(const RoadPriorityClass::Enum new_value) { road_priority_class = new_value; } bool operator==(const RoadClassification &other) const { return motorway_class == other.motorway_class && link_class == other.link_class && may_be_ignored == other.may_be_ignored && road_priority_class == other.road_priority_class; } bool operator!=(const RoadClassification &other) const { return !(*this == other); } std::string ToString() const { return std::string() + (motorway_class ? "motorway" : "normal") + (link_class ? "_link" : "") + (may_be_ignored ? " ignorable " : " important ") + std::to_string(road_priority_class); } }; #pragma pack(pop) static_assert( sizeof(RoadClassification) == 2, "Road Classification should fit two bytes. Increasing this has a severe impact on memory."); inline bool canBeSeenAsFork(const RoadClassification first, const RoadClassification second) { return std::abs(static_cast<int>(first.GetPriority()) - static_cast<int>(second.GetPriority())) <= 1; } // priority groups are road classes that can be categoriesed as somewhat similar inline std::uint8_t getRoadGroup(const RoadClassification classification) { const constexpr std::uint8_t groups[RoadPriorityClass::CONNECTIVITY + 1] = { 0, // MOTORWAY 0, // MOTORWAY_LINK 1, // TRUNK 1, // TRUNK_LINK 2, // PRIMARY 2, // PRIMARY_LINK 2, // SECONDARY 2, // SECONDARY_LINK 2, // TERTIARY 2, // TERTIARY_LINK 3, // MAIN_RESIDENTIAL 3, // SIDE_RESIDENTIAL 3, // ALLEY 3, // PARKING 4, // LINK_ROAD 4, // UNCLASSIFIED 5, // BIKE_PATH 6, // FOOT_PATH 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 // CONNECTIVITY }; BOOST_ASSERT(groups[RoadPriorityClass::CONNECTIVITY] == 7); return groups[classification.GetPriority()]; } // LHS road classification is strictly less than RHS, if it belongs to a lower general category // of roads. E.g. normal city roads are strictly less of a priority than a motorway and alleys // are strictly less than inner-city roads. inline bool strictlyLess(const RoadClassification lhs, const RoadClassification rhs) { if (!lhs.IsLowPriorityRoadClass() && rhs.IsLowPriorityRoadClass()) return false; if (lhs.IsLowPriorityRoadClass() && !rhs.IsLowPriorityRoadClass()) return true; return getRoadGroup(lhs) > getRoadGroup(rhs); } // check whether a link class is the fitting link class to a road inline bool isLinkTo(const RoadClassification link, const RoadClassification road) { // needs to be a link/non-link combination if (!link.IsLinkClass() || road.IsLinkClass()) return false; switch (link.GetPriority()) { case RoadPriorityClass::MOTORWAY_LINK: return road.GetPriority() == RoadPriorityClass::MOTORWAY; case RoadPriorityClass::TRUNK_LINK: return road.GetPriority() == RoadPriorityClass::TRUNK; case RoadPriorityClass::PRIMARY_LINK: return road.GetPriority() == RoadPriorityClass::PRIMARY; case RoadPriorityClass::SECONDARY_LINK: return road.GetPriority() == RoadPriorityClass::SECONDARY; case RoadPriorityClass::TERTIARY_LINK: return road.GetPriority() == RoadPriorityClass::TERTIARY; default: return false; } } inline bool obviousByRoadClass(const RoadClassification in_classification, const RoadClassification obvious_candidate, const RoadClassification compare_candidate) { // lower numbers are of higher priority const bool has_high_priority = intersection::PRIORITY_DISTINCTION_FACTOR * obvious_candidate.GetPriority() < compare_candidate.GetPriority(); const bool continues_on_same_class = in_classification == obvious_candidate; return (has_high_priority && continues_on_same_class) || (!obvious_candidate.IsLowPriorityRoadClass() && !in_classification.IsLowPriorityRoadClass() && compare_candidate.IsLowPriorityRoadClass()); } } // namespace osrm::extractor #endif // OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
Save
cmd:
run