migrated out of edge based graph factory

This commit is contained in:
Moritz Kobitzsch
2016-02-25 14:40:26 +01:00
committed by Patrick Niklaus
parent 6605f293b4
commit daf2bbf991
9 changed files with 975 additions and 843 deletions
-1
View File
@@ -86,7 +86,6 @@ class RouteAPI : public BaseAPI
leg_geometries.reserve(number_of_legs);
unpacked_path_segments = guidance::postProcess(std::move(unpacked_path_segments));
BOOST_ASSERT(locations.size() == number_of_legs + 1);
for (auto idx : util::irange(0UL, number_of_legs))
{
const auto &phantoms = segment_end_coordinates[idx];
+1 -1
View File
@@ -79,7 +79,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
steps.reserve(number_of_segments);
// TODO do computation based on distance and choose better next vertex
BOOST_ASSERT(leg_geometry.size() >= 4); // source, phantom, closest positions on way
BOOST_ASSERT(leg_geometry.locations.size() >= 4); // source, phantom, closest positions on way
const auto initial_modifier =
source_location
? angleToDirectionModifier(util::coordinate_calculation::computeAngle(
@@ -51,7 +51,7 @@ classifyIntersection(NodeID nid,
const auto base_coordinate = getRepresentativeCoordinate(nid, graph.GetTarget(base_id), base_id,
graph.GetEdgeData(base_id).reversed,
compressed_geometries, query_nodes);
const auto node_coordinate = Coordinate(query_nodes[nid].lon, query_nodes[nid].lat);
const auto node_coordinate = util::Coordinate(query_nodes[nid].lon, query_nodes[nid].lat);
// generate a list of all turn angles between a base edge, the node and a current edge
for (const EdgeID eid : graph.GetAdjacentEdgeRange(nid))
+2 -44
View File
@@ -10,6 +10,7 @@
#include "extractor/edge_based_node.hpp"
#include "extractor/original_edge_data.hpp"
#include "extractor/query_node.hpp"
#include "extractor/turn_analysis.hpp"
#include "engine/guidance/turn_instruction.hpp"
@@ -128,52 +129,9 @@ class EdgeBasedGraphFactory
void FlushVectorToStream(std::ofstream &edge_data_file,
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
struct TurnCandidate
{
EdgeID eid; // the id of the arc
bool valid; // a turn may be relevant to good instructions, even if we cannot take the road
double angle; // the approximated angle of the turn
engine::guidance::TurnInstruction instruction; // a proposed instruction
double confidence; // how close to the border is the turn?
std::string toString() const
{
std::string result = "[turn] ";
result += std::to_string(eid);
result += " valid: ";
result += std::to_string(valid);
result += " angle: ";
result += std::to_string(angle);
result += " instruction: ";
result += std::to_string(static_cast<std::int32_t>(instruction.type)) + " " +
std::to_string(static_cast<std::int32_t>(instruction.direction_modifier));
result += " confidence: ";
result += std::to_string(confidence);
return result;
}
};
// Use In Order to generate base turns
std::vector<TurnCandidate> getTurns(const NodeID from, const EdgeID via_edge);
// cannot be const due to the counters...
std::vector<TurnCandidate> getTurnCandidates(const NodeID from, const EdgeID via_edge);
std::vector<TurnCandidate> optimizeCandidates(const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const;
std::vector<TurnCandidate> optimizeRamps(const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const;
engine::guidance::TurnType
checkForkAndEnd(const EdgeID via_edge, const std::vector<TurnCandidate> &turn_candidates) const;
std::vector<TurnCandidate> handleForkAndEnd(const engine::guidance::TurnType type,
std::vector<TurnCandidate> turn_candidates) const;
std::vector<TurnCandidate> suppressTurns(const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates) const;
bool isObviousChoice(const EdgeID coming_from_eid,
const std::size_t turn_index,
const std::vector<TurnCandidate> &turn_candidates) const;
std::size_t restricted_turns_counter;
std::size_t skipped_uturns_counter;
+109
View File
@@ -0,0 +1,109 @@
#ifndef OSRM_EXTRACTOR_TURN_ANALYSIS
#define OSRM_EXTRACTOR_TURN_ANALYSIS
#include "engine/guidance/turn_classification.hpp"
#include "engine/guidance/guidance_toolkit.hpp"
#include "extractor/restriction_map.hpp"
#include "extractor/compressed_edge_container.hpp"
#include <unordered_set>
namespace osrm
{
namespace extractor
{
struct TurnCandidate
{
EdgeID eid; // the id of the arc
bool valid; // a turn may be relevant to good instructions, even if we cannot take the road
double angle; // the approximated angle of the turn
engine::guidance::TurnInstruction instruction; // a proposed instruction
double confidence; // how close to the border is the turn?
std::string toString() const
{
std::string result = "[turn] ";
result += std::to_string(eid);
result += " valid: ";
result += std::to_string(valid);
result += " angle: ";
result += std::to_string(angle);
result += " instruction: ";
result += std::to_string(static_cast<std::int32_t>(instruction.type)) + " " +
std::to_string(static_cast<std::int32_t>(instruction.direction_modifier));
result += " confidence: ";
result += std::to_string(confidence);
return result;
}
};
namespace turn_analysis
{
std::vector<TurnCandidate>
getTurns(const NodeID from_node,
const EdgeID via_eid,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph,
const std::vector<QueryNode> &node_info_list,
const std::shared_ptr<RestrictionMap const> restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const CompressedEdgeContainer &compressed_edge_container);
std::vector<TurnCandidate>
setTurnTypes(const NodeID from,
const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
std::vector<TurnCandidate>
optimizeRamps(const EdgeID via_edge,
std::vector<TurnCandidate> turn_candidates,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
engine::guidance::TurnType
checkForkAndEnd(const EdgeID via_eid,
const std::vector<TurnCandidate> &turn_candidates,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
std::vector<TurnCandidate> handleForkAndEnd(const engine::guidance::TurnType type,
std::vector<TurnCandidate> turn_candidates);
std::vector<TurnCandidate>
optimizeCandidates(const EdgeID via_eid,
std::vector<TurnCandidate> turn_candidates,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph,
const std::vector<QueryNode> &node_info_list);
bool isObviousChoice(const EdgeID via_eid,
const std::size_t turn_index,
const std::vector<TurnCandidate> &turn_candidates,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
std::vector<TurnCandidate>
suppressTurns(const EdgeID via_eid,
std::vector<TurnCandidate> turn_candidates,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
std::vector<TurnCandidate>
getTurnCandidates(const NodeID from_node,
const EdgeID via_eid,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph,
const std::vector<QueryNode> &node_info_list,
const std::shared_ptr<RestrictionMap const> restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const CompressedEdgeContainer &compressed_edge_container);
// node_u -- (edge_1) --> node_v -- (edge_2) --> node_w
engine::guidance::TurnInstruction
AnalyzeTurn(const NodeID node_u,
const EdgeID edge1,
const NodeID node_v,
const EdgeID edge2,
const NodeID node_w,
const double angle,
const std::shared_ptr<const util::NodeBasedDynamicGraph> node_based_graph);
} // namespace turn_analysis
} // namespace extractor
} // namespace osrm
#endif // OSRM_EXTRACTOR_TURN_ANALYSIS