Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
isThroughStreet
/Intersection options (#4751)
* refactor isThroughStreet * refactor HaveIdenticalName * fix a typo in the unit tests
- Loading branch information
Showing
18 changed files
with
229 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_ | ||
#define OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_ | ||
|
||
#include "extractor/guidance/constants.hpp" | ||
#include "extractor/suffix_table.hpp" | ||
#include "util/name_table.hpp" | ||
|
||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
namespace guidance | ||
{ | ||
|
||
// check if two name ids can be seen as identical (in presence of refs/others) | ||
// in our case this translates into no name announcement in either direction (lhs->rhs and | ||
// rhs->lhs) | ||
bool HaveIdenticalNames(const NameID lhs, | ||
const NameID rhs, | ||
const util::NameTable &name_table, | ||
const SuffixTable &street_name_suffix_table); | ||
|
||
} // namespace guidance | ||
} // namespace extractor | ||
} // namespace osrm | ||
|
||
#endif /*OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_ | ||
#define OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_ | ||
|
||
#include "extractor/guidance/constants.hpp" | ||
#include "extractor/suffix_table.hpp" | ||
#include "util/guidance/name_announcements.hpp" | ||
|
||
using osrm::util::angularDeviation; | ||
|
||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
namespace guidance | ||
{ | ||
|
||
template <typename IntersectionType> | ||
inline bool isThroughStreet(const std::size_t index, | ||
const IntersectionType &intersection, | ||
const util::NodeBasedDynamicGraph &node_based_graph, | ||
const EdgeBasedNodeDataContainer &node_data_container, | ||
const util::NameTable &name_table, | ||
const SuffixTable &street_name_suffix_table) | ||
{ | ||
|
||
const auto &data_at_index = node_data_container.GetAnnotation( | ||
node_based_graph.GetEdgeData(intersection[index].eid).annotation_data); | ||
|
||
if (data_at_index.name_id == EMPTY_NAMEID) | ||
return false; | ||
|
||
// a through street cannot start at our own position -> index 1 | ||
for (std::size_t road_index = 1; road_index < intersection.size(); ++road_index) | ||
{ | ||
if (road_index == index) | ||
continue; | ||
|
||
const auto &road = intersection[road_index]; | ||
const auto &road_data = node_data_container.GetAnnotation( | ||
node_based_graph.GetEdgeData(road.eid).annotation_data); | ||
|
||
// roads have a near straight angle (180 degree) | ||
const bool is_nearly_straight = angularDeviation(road.angle, intersection[index].angle) > | ||
(STRAIGHT_ANGLE - FUZZY_ANGLE_DIFFERENCE); | ||
|
||
const bool have_same_name = HaveIdenticalNames( | ||
data_at_index.name_id, road_data.name_id, name_table, street_name_suffix_table); | ||
|
||
const bool have_same_category = | ||
node_based_graph.GetEdgeData(intersection[index].eid).flags.road_classification == | ||
node_based_graph.GetEdgeData(road.eid).flags.road_classification; | ||
|
||
if (is_nearly_straight && have_same_name && have_same_category) | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} // namespace guidance | ||
} // namespace extractor | ||
} // namespace osrm | ||
|
||
#endif /*OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_ | ||
#define OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_ | ||
|
||
#include "util/guidance/name_announcements.hpp" | ||
|
||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
namespace guidance | ||
{ | ||
|
||
// check if two name ids can be seen as identical (in presence of refs/others) | ||
// in our case this translates into no name announcement in either direction (lhs->rhs and | ||
// rhs->lhs) | ||
bool HaveIdenticalNames(const NameID lhs, | ||
const NameID rhs, | ||
const util::NameTable &name_table, | ||
const SuffixTable &street_name_suffix_table) | ||
{ | ||
const auto non_empty = (lhs != EMPTY_NAMEID) && (rhs != EMPTY_NAMEID); | ||
|
||
// symmetrical check for announcements | ||
return non_empty && | ||
!util::guidance::requiresNameAnnounced(lhs, rhs, name_table, street_name_suffix_table) && | ||
!util::guidance::requiresNameAnnounced(rhs, lhs, name_table, street_name_suffix_table); | ||
} | ||
|
||
} // namespace guidance | ||
} // namespace extractor | ||
} // namespace osrm | ||
|
||
#endif /*OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.