This commit is contained in:
Huyen Chau Nguyen 2018-09-09 22:49:32 +03:00
parent 91a24bf537
commit 4a4d7ac62f
12 changed files with 71 additions and 60 deletions

View File

@ -46,15 +46,14 @@ namespace engine
struct PhantomNode struct PhantomNode
{ {
PhantomNode() PhantomNode()
: forward_segment_id{SPECIAL_SEGMENTID, false}, reverse_segment_id{SPECIAL_SEGMENTID, : forward_segment_id{SPECIAL_SEGMENTID, false},
false}, reverse_segment_id{SPECIAL_SEGMENTID, false}, forward_weight(INVALID_EDGE_WEIGHT),
forward_weight(INVALID_EDGE_WEIGHT), reverse_weight(INVALID_EDGE_WEIGHT), reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
forward_weight_offset(0), reverse_weight_offset(0),
forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE), forward_distance(INVALID_EDGE_DISTANCE), reverse_distance(INVALID_EDGE_DISTANCE),
forward_distance_offset(0), reverse_distance_offset(0), forward_distance_offset(0), reverse_distance_offset(0),
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION), forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
forward_duration_offset(0), reverse_duration_offset(0), forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0),
fwd_segment_position(0), is_valid_forward_source{false}, is_valid_forward_target{false}, is_valid_forward_source{false}, is_valid_forward_target{false},
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0) is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)
{ {
@ -112,9 +111,8 @@ struct PhantomNode
bool IsValid(const unsigned number_of_nodes) const bool IsValid(const unsigned number_of_nodes) const
{ {
return location.IsValid() && return location.IsValid() && ((forward_segment_id.id < number_of_nodes) ||
((forward_segment_id.id < number_of_nodes) || (reverse_segment_id.id < number_of_nodes)) &&
(reverse_segment_id.id < number_of_nodes)) &&
((forward_weight != INVALID_EDGE_WEIGHT) || ((forward_weight != INVALID_EDGE_WEIGHT) ||
(reverse_weight != INVALID_EDGE_WEIGHT)) && (reverse_weight != INVALID_EDGE_WEIGHT)) &&
((forward_duration != MAXIMAL_EDGE_DURATION) || ((forward_duration != MAXIMAL_EDGE_DURATION) ||

View File

@ -186,7 +186,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
} }
template <bool UseDuration> template <bool UseDuration>
std::tuple<EdgeWeight,EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node) std::tuple<EdgeWeight, EdgeDistance> getLoopWeight(const DataFacade<Algorithm> &facade, NodeID node)
{ {
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT; EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
EdgeDistance loop_distance = MAXIMAL_EDGE_DISTANCE; EdgeDistance loop_distance = MAXIMAL_EDGE_DISTANCE;

View File

@ -9,8 +9,8 @@
#include <tbb/parallel_sort.h> #include <tbb/parallel_sort.h>
#include <memory>
#include <iostream> #include <iostream>
#include <memory>
#include <utility> #include <utility>
namespace osrm namespace osrm
@ -88,10 +88,10 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
output_edge.data.flags = input_edge.flags; output_edge.data.flags = input_edge.flags;
output_edge.data.annotation_data = input_edge.annotation_data; output_edge.data.annotation_data = input_edge.annotation_data;
BOOST_ASSERT(output_edge.data.weight >= 0); BOOST_ASSERT(output_edge.data.weight >= 0);
BOOST_ASSERT(output_edge.data.duration >= 0); BOOST_ASSERT(output_edge.data.duration >= 0);
if (output_edge.data.distance <= 0) { if (output_edge.data.distance <= 0)
{
std::cout << "output_edge.data.distance " << output_edge.data.distance << std::endl; std::cout << "output_edge.data.distance " << output_edge.data.distance << std::endl;
} }
BOOST_ASSERT(output_edge.data.distance >= 0); BOOST_ASSERT(output_edge.data.distance >= 0);

View File

@ -555,21 +555,21 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
&scripting_environment, &scripting_environment,
weight_multiplier, weight_multiplier,
&conditional_restriction_map]( &conditional_restriction_map](
// what nodes will be used? In most cases this will be the id // what nodes will be used? In most cases this will be the id
// stored in the edge_data. In case of duplicated nodes (e.g. // stored in the edge_data. In case of duplicated nodes (e.g.
// due to via-way restrictions), one/both of these might // due to via-way restrictions), one/both of these might
// refer to a newly added edge based node // refer to a newly added edge based node
const auto edge_based_node_from, const auto edge_based_node_from,
const auto edge_based_node_to, const auto edge_based_node_to,
// the situation of the turn // the situation of the turn
const auto node_along_road_entering, const auto node_along_road_entering,
const auto node_based_edge_from, const auto node_based_edge_from,
const auto intersection_node, const auto intersection_node,
const auto node_based_edge_to, const auto node_based_edge_to,
const auto &turn_angle, const auto &turn_angle,
const auto &road_legs_on_the_right, const auto &road_legs_on_the_right,
const auto &road_legs_on_the_left, const auto &road_legs_on_the_left,
const auto &edge_geometries) { const auto &edge_geometries) {
const auto node_restricted = const auto node_restricted =
isRestricted(node_along_road_entering, isRestricted(node_along_road_entering,
intersection_node, intersection_node,
@ -890,7 +890,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// TODO: this loop is not optimized - once we have a few // TODO: this loop is not optimized - once we have a few
// overrides available, we should index this for faster // overrides available, we should index this for faster
// lookups // lookups
for (auto &override : unresolved_maneuver_overrides) for (auto & override : unresolved_maneuver_overrides)
{ {
for (auto &turn : override.turn_sequence) for (auto &turn : override.turn_sequence)
{ {

View File

@ -277,8 +277,8 @@ void ExtractionContainers::PrepareEdges(ScriptingEnvironment &scripting_environm
{ {
if (edge_iterator->result.osm_source_id < node_iterator->node_id) if (edge_iterator->result.osm_source_id < node_iterator->node_id)
{ {
util::Log(logDEBUG) util::Log(logDEBUG) << "Found invalid node reference "
<< "Found invalid node reference " << edge_iterator->result.source; << edge_iterator->result.source;
edge_iterator->result.source = SPECIAL_NODEID; edge_iterator->result.source = SPECIAL_NODEID;
++edge_iterator; ++edge_iterator;
continue; continue;
@ -1038,9 +1038,8 @@ void ExtractionContainers::PrepareRestrictions()
// translate the turn from one segment onto another into a node restriction (the ways can // translate the turn from one segment onto another into a node restriction (the ways can
// only // only
// be connected at a single location) // be connected at a single location)
auto const get_node_restriction_from_OSM_ids = [&](auto const from_id, auto const get_node_restriction_from_OSM_ids = [&](
auto const to_id, auto const from_id, auto const to_id, const OSMNodeID via_node) {
const OSMNodeID via_node) {
auto const from_segment_itr = referenced_ways.find(from_id); auto const from_segment_itr = referenced_ways.find(from_id);
if (from_segment_itr->second.way_id != from_id) if (from_segment_itr->second.way_id != from_id)
{ {

View File

@ -75,7 +75,7 @@ void ExtractorCallbacks::ProcessRestriction(const InputConditionalTurnRestrictio
// util::Log() << restriction.toString(); // util::Log() << restriction.toString();
} }
void ExtractorCallbacks::ProcessManeuverOverride(const InputManeuverOverride &override) void ExtractorCallbacks::ProcessManeuverOverride(const InputManeuverOverride & override)
{ {
external_memory.external_maneuver_overrides_list.push_back(override); external_memory.external_maneuver_overrides_list.push_back(override);
} }

View File

@ -185,18 +185,17 @@ void GraphCompressor::Compress(
* just * just
* like a barrier. * like a barrier.
*/ */
const auto selectAnnotation = const auto selectAnnotation = [&node_data_container](
[&node_data_container](const AnnotationID front_annotation, const AnnotationID front_annotation, const AnnotationID back_annotation) {
const AnnotationID back_annotation) { // A lane has tags: u - (front) - v - (back) - w
// A lane has tags: u - (front) - v - (back) - w // During contraction, we keep only one of the tags. Usually the one closer
// During contraction, we keep only one of the tags. Usually the one closer // to the intersection is preferred. If its empty, however, we keep the
// to the intersection is preferred. If its empty, however, we keep the // non-empty one
// non-empty one if (node_data_container[back_annotation].lane_description_id ==
if (node_data_container[back_annotation].lane_description_id == INVALID_LANE_DESCRIPTIONID)
INVALID_LANE_DESCRIPTIONID) return front_annotation;
return front_annotation; return back_annotation;
return back_annotation; };
};
graph.GetEdgeData(forward_e1).annotation_data = selectAnnotation( graph.GetEdgeData(forward_e1).annotation_data = selectAnnotation(
fwd_edge_data1.annotation_data, fwd_edge_data2.annotation_data); fwd_edge_data1.annotation_data, fwd_edge_data2.annotation_data);

View File

@ -81,7 +81,10 @@ return_code parseArguments(int argc,
"time-zone-file", "time-zone-file",
boost::program_options::value<std::string>(&contractor_config.updater_config.tz_file_path), boost::program_options::value<std::string>(&contractor_config.updater_config.tz_file_path),
"Required for conditional turn restriction parsing, provide a geojson file containing " "Required for conditional turn restriction parsing, provide a geojson file containing "
"time zone boundaries")("cache-distances",boost::program_options::bool_switch(&contractor_config.cache_distances)->default_value(false), "time zone boundaries")(
"cache-distances",
boost::program_options::bool_switch(&contractor_config.cache_distances)
->default_value(false),
"Store distances for CH edges, avoiding the need for query-time re-calculation."); "Store distances for CH edges, avoiding the need for query-time re-calculation.");
// hidden options, will be allowed on command line, but will not be shown to the user // hidden options, will be allowed on command line, but will not be shown to the user

View File

@ -51,7 +51,8 @@
// return false; // return false;
// auto const &first_annotation = node_data_container[graph.GetEdgeData(first).annotation_data]; // auto const &first_annotation = node_data_container[graph.GetEdgeData(first).annotation_data];
// auto const &second_annotation = node_data_container[graph.GetEdgeData(second).annotation_data]; // auto const &second_annotation =
// node_data_container[graph.GetEdgeData(second).annotation_data];
// return first_annotation.CanCombineWith(second_annotation); // return first_annotation.CanCombineWith(second_annotation);
// } // }

View File

@ -169,7 +169,8 @@ using Graph = util::NodeBasedDynamicGraph;
// // 0 // // 0
// // ↙ ↑ ↘ // // ↙ ↑ ↘
// // 4 5 6 // // 4 5 6
// const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout) { // const auto unit_edge = [](const NodeID from, const NodeID to, bool allowed, bool roundabout)
// {
// return InputEdge{from, // return InputEdge{from,
// to, // to,
// 1, // 1,

View File

@ -15,7 +15,8 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
// const char json[] = // const char json[] =
// "{ \"type\" : \"FeatureCollection\", \"features\": [" // "{ \"type\" : \"FeatureCollection\", \"features\": ["
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
// \"polygon\", "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] }} ]}"; // "49.07206], [8.28369, 48.88277]]] }} ]}";
@ -29,7 +30,8 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
// const char bad[] = // const char bad[] =
// "\"type\" : \"FeatureCollection\", \"features\": [" // "\"type\" : \"FeatureCollection\", \"features\": ["
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
// \"polygon\", "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] }} ]}"; // "49.07206], [8.28369, 48.88277]]] }} ]}";
@ -39,7 +41,8 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
// const char missing_type[] = // const char missing_type[] =
// "{ \"FeatureCollection\", \"features\": [" // "{ \"FeatureCollection\", \"features\": ["
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
// \"polygon\", "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] }} ]}"; // "49.07206], [8.28369, 48.88277]]] }} ]}";
@ -48,7 +51,8 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
// const char missing_featc[] = // const char missing_featc[] =
// "{ \"type\" : \"Collection\", \"features\": [" // "{ \"type\" : \"Collection\", \"features\": ["
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
// \"polygon\", "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] }} ]}"; // "49.07206], [8.28369, 48.88277]]] }} ]}";

View File

@ -74,7 +74,8 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception); // BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
// char tzid_err[] = "{ \"type\" : \"Feature\"," // char tzid_err[] = "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\",
// "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] }}"; // "49.07206], [8.28369, 48.88277]]] }}";
@ -92,7 +93,8 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
// char nonobj_geom[] = // char nonobj_geom[] =
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : [ \"type\", \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : [ \"type\",
// \"polygon\", "
// "\"coordinates\", [[[8.28369,48.88277], [8.57757, " // "\"coordinates\", [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] ]}"; // "49.07206], [8.28369, 48.88277]]] ]}";
@ -100,7 +102,8 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception); // BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
// char missing_geom_type[] = "{ \"type\" : \"Feature\"," // char missing_geom_type[] = "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" :
// { "
// "\"no_type\": \"polygon\", " // "\"no_type\": \"polygon\", "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
@ -109,7 +112,8 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
// BOOST_CHECK_THROW(util::validateFeature(doc), util::exception); // BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
// char nonstring_geom_type[] = "{ \"type\" : \"Feature\"," // char nonstring_geom_type[] = "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\"
// : "
// "{ \"type\": [\"polygon\"], " // "{ \"type\": [\"polygon\"], "
// "\"coordinates\": [[[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
@ -119,7 +123,8 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
// char missing_coords[] = // char missing_coords[] =
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
// \"polygon\", "
// "\"coords\": [[[8.28369,48.88277], [8.57757, " // "\"coords\": [[[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]]] }}"; // "49.07206], [8.28369, 48.88277]]] }}";
@ -128,7 +133,8 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
// char missing_outerring[] = // char missing_outerring[] =
// "{ \"type\" : \"Feature\"," // "{ \"type\" : \"Feature\","
// "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\": \"polygon\", " // "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometry\" : { \"type\":
// \"polygon\", "
// "\"coordinates\": [[8.28369,48.88277], [8.57757, " // "\"coordinates\": [[8.28369,48.88277], [8.57757, "
// "48.88277], [8.57757, 49.07206], [8.28369, " // "48.88277], [8.57757, 49.07206], [8.28369, "
// "49.07206], [8.28369, 48.88277]] }}"; // "49.07206], [8.28369, 48.88277]] }}";