enable suppression name suffix changes

This commit is contained in:
Moritz Kobitzsch
2016-04-22 11:31:46 +02:00
parent fddb035539
commit a154d71841
21 changed files with 298 additions and 95 deletions
+4 -1
View File
@@ -9,6 +9,7 @@
#include "util/simple_logger.hpp"
#include "util/timing_util.hpp"
#include "extractor/suffix_table.hpp"
#include "extractor/guidance/toolkit.hpp"
#include <boost/assert.hpp>
@@ -320,8 +321,10 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// Three nested loop look super-linear, but we are dealing with a (kind of)
// linear number of turns only.
util::Percent progress(m_node_based_graph->GetNumberOfNodes());
SuffixTable street_name_suffix_table(lua_state);
guidance::TurnAnalysis turn_analysis(*m_node_based_graph, m_node_info_list, *m_restriction_map,
m_barrier_nodes, m_compressed_edge_container, name_table);
m_barrier_nodes, m_compressed_edge_container, name_table,
street_name_suffix_table);
for (const auto node_u : util::irange(0u, m_node_based_graph->GetNumberOfNodes()))
{
progress.printStatus(node_u);
@@ -27,8 +27,10 @@ inline bool requiresAnnouncement(const EdgeData &from, const EdgeData &to)
IntersectionHandler::IntersectionHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<QueryNode> &node_info_list,
const util::NameTable &name_table)
: node_based_graph(node_based_graph), node_info_list(node_info_list), name_table(name_table)
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
: node_based_graph(node_based_graph), node_info_list(node_info_list), name_table(name_table),
street_name_suffix_table(street_name_suffix_table)
{
}
@@ -86,7 +88,8 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t
const auto &out_data = node_based_graph.GetEdgeData(road.turn.eid);
if (in_data.name_id != out_data.name_id &&
requiresNameAnnounced(name_table.GetNameForID(in_data.name_id),
name_table.GetNameForID(out_data.name_id)))
name_table.GetNameForID(out_data.name_id),
street_name_suffix_table))
{
// obvious turn onto a through street is a merge
if (through_street)
+3 -2
View File
@@ -44,8 +44,9 @@ inline bool isRampClass(EdgeID eid, const util::NodeBasedDynamicGraph &node_base
MotorwayHandler::MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<QueryNode> &node_info_list,
const util::NameTable &name_table)
: IntersectionHandler(node_based_graph, node_info_list, name_table)
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph, node_info_list, name_table, street_name_suffix_table)
{
}
+10 -6
View File
@@ -23,9 +23,10 @@ namespace guidance
RoundaboutHandler::RoundaboutHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<QueryNode> &node_info_list,
const CompressedEdgeContainer &compressed_edge_container,
const util::NameTable &name_table,
const CompressedEdgeContainer &compressed_edge_container)
: IntersectionHandler(node_based_graph, node_info_list, name_table),
const SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph, node_info_list, name_table, street_name_suffix_table),
compressed_edge_container(compressed_edge_container)
{
}
@@ -142,9 +143,11 @@ bool RoundaboutHandler::qualifiesAsRoundaboutIntersection(
if (!has_limited_size)
return false;
const bool simple_exits = !std::find_if( roundabout_nodes.begin(), roundabout_nodes.end(), [this]( const NodeID node ){
return (node_based_graph.GetOutDegree(node) > 3);
});
const bool simple_exits =
roundabout_nodes.end() ==
std::find_if(roundabout_nodes.begin(), roundabout_nodes.end(), [this](const NodeID node) {
return (node_based_graph.GetOutDegree(node) > 3);
});
if (!simple_exits)
return false;
@@ -219,7 +222,8 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
// roundabout does not keep its name
if (roundabout_name_id != 0 && roundabout_name_id != edge_data.name_id &&
requiresNameAnnounced(name_table.GetNameForID(roundabout_name_id),
name_table.GetNameForID(edge_data.name_id)))
name_table.GetNameForID(edge_data.name_id),
street_name_suffix_table))
{
return SPECIAL_EDGEID;
}
+5 -4
View File
@@ -33,15 +33,16 @@ TurnAnalysis::TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
const RestrictionMap &restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const CompressedEdgeContainer &compressed_edge_container,
const util::NameTable &name_table)
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
: node_based_graph(node_based_graph), intersection_generator(node_based_graph,
restriction_map,
barrier_nodes,
node_info_list,
compressed_edge_container),
roundabout_handler(node_based_graph, node_info_list, name_table, compressed_edge_container),
motorway_handler(node_based_graph, node_info_list, name_table),
turn_handler(node_based_graph, node_info_list, name_table)
roundabout_handler(node_based_graph, node_info_list, compressed_edge_container, name_table, street_name_suffix_table),
motorway_handler(node_based_graph, node_info_list, name_table,street_name_suffix_table),
turn_handler(node_based_graph, node_info_list, name_table,street_name_suffix_table)
{
}
+13 -11
View File
@@ -24,8 +24,9 @@ namespace guidance
TurnHandler::TurnHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<QueryNode> &node_info_list,
const util::NameTable &name_table)
: IntersectionHandler(node_based_graph, node_info_list, name_table)
const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table)
: IntersectionHandler(node_based_graph, node_info_list, name_table, street_name_suffix_table)
{
}
@@ -406,22 +407,23 @@ Intersection TurnHandler::assignLeftTurns(const EdgeID via_edge,
Intersection intersection,
const std::size_t starting_at) const
{
BOOST_ASSERT(!intersection.empty());
BOOST_ASSERT(starting_at <= intersection.size());
for (auto &road : intersection)
road = mirror(road);
const auto switch_left_and_right = []( Intersection &intersection )
{
BOOST_ASSERT(!intersection.empty());
std::reverse(intersection.begin() + 1, intersection.end());
for (auto &road : intersection)
road = mirror(std::move(road));
std::reverse(intersection.begin() + 1, intersection.end());
};
switch_left_and_right(intersection);
// account for the u-turn in the beginning
const auto count = intersection.size() - starting_at + 1;
intersection = assignRightTurns(via_edge, std::move(intersection), count);
switch_left_and_right(intersection);
std::reverse(intersection.begin() + 1, intersection.end());
for (auto &road : intersection)
road = mirror(road);
return intersection;
}
+48
View File
@@ -0,0 +1,48 @@
#include "extractor/suffix_table.hpp"
#include "util/lua_util.hpp"
#include "util/simple_logger.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/assert.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/ref.hpp>
#include <iterator>
#include <vector>
namespace osrm
{
namespace extractor
{
SuffixTable::SuffixTable(lua_State *lua_state)
{
BOOST_ASSERT(lua_state != nullptr);
if (!util::luaFunctionExists(lua_state, "get_name_suffix_list"))
return;
std::vector<std::string> suffixes_vector;
try
{
// call lua profile to compute turn penalty
luabind::call_function<void>(lua_state, "get_name_suffix_list",
boost::ref(suffixes_vector));
}
catch (const luabind::error &er)
{
util::SimpleLogger().Write(logWARNING) << er.what();
}
for (auto &suffix : suffixes_vector)
boost::algorithm::to_lower(suffix);
suffix_set.insert(std::begin(suffixes_vector), std::end(suffixes_vector));
}
bool SuffixTable::isSuffix(const std::string &possible_suffix) const
{
return suffix_set.count(possible_suffix) > 0;
}
} /* namespace extractor */
} /* namespace osrm */