Avoid -> Exclude
This commit is contained in:
committed by
Patrick Niklaus
parent
45140ca9f7
commit
d09f5c0e3a
@@ -56,7 +56,7 @@ template <typename AlgorithmT> struct HasManyToManySearch final : std::false_typ
|
||||
template <typename AlgorithmT> struct HasGetTileTurns final : std::false_type
|
||||
{
|
||||
};
|
||||
template <typename AlgorithmT> struct HasAvoidFlags final : std::false_type
|
||||
template <typename AlgorithmT> struct HasExcludeFlags final : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ template <> struct HasManyToManySearch<mld::Algorithm> final : std::true_type
|
||||
template <> struct HasGetTileTurns<mld::Algorithm> final : std::true_type
|
||||
{
|
||||
};
|
||||
template <> struct HasAvoidFlags<mld::Algorithm> final : std::true_type
|
||||
template <> struct HasExcludeFlags<mld::Algorithm> final : std::true_type
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ struct BaseParameters
|
||||
std::vector<boost::optional<double>> radiuses;
|
||||
std::vector<boost::optional<Bearing>> bearings;
|
||||
std::vector<boost::optional<Approach>> approaches;
|
||||
std::vector<std::string> avoid;
|
||||
std::vector<std::string> exclude;
|
||||
|
||||
// Adds hints to response which can be included in subsequent requests, see `hints` above.
|
||||
bool generate_hints = true;
|
||||
@@ -79,9 +79,9 @@ struct BaseParameters
|
||||
std::vector<boost::optional<Bearing>> bearings_ = {},
|
||||
std::vector<boost::optional<Approach>> approaches_ = {},
|
||||
bool generate_hints_ = true,
|
||||
std::vector<std::string> avoid = {})
|
||||
std::vector<std::string> exclude = {})
|
||||
: coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_),
|
||||
approaches(approaches_), avoid(std::move(avoid)), generate_hints(generate_hints_)
|
||||
approaches(approaches_), exclude(std::move(exclude)), generate_hints(generate_hints_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
using SharedGeospatialQuery = GeospatialQuery<SharedRTree, BaseDataFacade>;
|
||||
using RTreeNode = SharedRTree::TreeNode;
|
||||
|
||||
extractor::ClassData avoid_mask;
|
||||
extractor::ClassData exclude_mask;
|
||||
std::string m_timestamp;
|
||||
extractor::ProfileProperties *m_profile_properties;
|
||||
extractor::Datasources *m_datasources;
|
||||
@@ -249,12 +249,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
void InitializeProfilePropertiesPointer(storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t avoid_index)
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
m_profile_properties = data_layout.GetBlockPtr<extractor::ProfileProperties>(
|
||||
memory_block, storage::DataLayout::PROPERTIES);
|
||||
|
||||
avoid_mask = m_profile_properties->avoidable_classes[avoid_index];
|
||||
exclude_mask = m_profile_properties->excludable_classes[exclude_index];
|
||||
}
|
||||
|
||||
void InitializeTimestampPointer(storage::DataLayout &data_layout, char *memory_block)
|
||||
@@ -546,7 +546,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t avoid_index)
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
InitializeChecksumPointer(data_layout, memory_block);
|
||||
InitializeNodeInformationPointers(data_layout, memory_block);
|
||||
@@ -557,7 +557,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
InitializeTimestampPointer(data_layout, memory_block);
|
||||
InitializeNamePointers(data_layout, memory_block);
|
||||
InitializeTurnLaneDescriptionsPointers(data_layout, memory_block);
|
||||
InitializeProfilePropertiesPointer(data_layout, memory_block, avoid_index);
|
||||
InitializeProfilePropertiesPointer(data_layout, memory_block, exclude_index);
|
||||
InitializeRTreePointers(data_layout, memory_block);
|
||||
InitializeIntersectionClassPointers(data_layout, memory_block);
|
||||
}
|
||||
@@ -566,10 +566,10 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
// allows switching between process_memory/shared_memory datafacade, based on the type of
|
||||
// allocator
|
||||
ContiguousInternalMemoryDataFacadeBase(std::shared_ptr<ContiguousBlockAllocator> allocator_,
|
||||
const std::size_t avoid_index)
|
||||
const std::size_t exclude_index)
|
||||
: allocator(std::move(allocator_))
|
||||
{
|
||||
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), avoid_index);
|
||||
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), exclude_index);
|
||||
}
|
||||
|
||||
// node and edge information access
|
||||
@@ -810,9 +810,9 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
return edge_based_node_data.GetClassData(id);
|
||||
}
|
||||
|
||||
bool AvoidNode(const NodeID id) const override final
|
||||
bool ExcludeNode(const NodeID id) const override final
|
||||
{
|
||||
return (edge_based_node_data.GetClassData(id) & avoid_mask) > 0;
|
||||
return (edge_based_node_data.GetClassData(id) & exclude_mask) > 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetClasses(const extractor::ClassData class_data) const override final
|
||||
@@ -940,8 +940,8 @@ class ContiguousInternalMemoryDataFacade<CH>
|
||||
{
|
||||
public:
|
||||
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator,
|
||||
const std::size_t avoid_index)
|
||||
: ContiguousInternalMemoryDataFacadeBase(allocator, avoid_index),
|
||||
const std::size_t exclude_index)
|
||||
: ContiguousInternalMemoryDataFacadeBase(allocator, exclude_index),
|
||||
ContiguousInternalMemoryAlgorithmDataFacade<CH>(allocator)
|
||||
|
||||
{
|
||||
@@ -955,8 +955,8 @@ class ContiguousInternalMemoryDataFacade<CoreCH> final
|
||||
{
|
||||
public:
|
||||
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator,
|
||||
const std::size_t avoid_index)
|
||||
: ContiguousInternalMemoryDataFacade<CH>(allocator, avoid_index),
|
||||
const std::size_t exclude_index)
|
||||
: ContiguousInternalMemoryDataFacade<CH>(allocator, exclude_index),
|
||||
ContiguousInternalMemoryAlgorithmDataFacade<CoreCH>(allocator)
|
||||
|
||||
{
|
||||
@@ -977,15 +977,15 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
|
||||
void InitializeInternalPointers(storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t avoid_index)
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
InitializeMLDDataPointers(data_layout, memory_block, avoid_index);
|
||||
InitializeMLDDataPointers(data_layout, memory_block, exclude_index);
|
||||
InitializeGraphPointer(data_layout, memory_block);
|
||||
}
|
||||
|
||||
void InitializeMLDDataPointers(storage::DataLayout &data_layout,
|
||||
char *memory_block,
|
||||
const std::size_t avoid_index)
|
||||
const std::size_t exclude_index)
|
||||
{
|
||||
if (data_layout.GetBlockSize(storage::DataLayout::MLD_PARTITION) > 0)
|
||||
{
|
||||
@@ -1013,9 +1013,9 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
}
|
||||
|
||||
const auto weights_block_id = static_cast<storage::DataLayout::BlockID>(
|
||||
storage::DataLayout::MLD_CELL_WEIGHTS_0 + avoid_index);
|
||||
storage::DataLayout::MLD_CELL_WEIGHTS_0 + exclude_index);
|
||||
const auto durations_block_id = static_cast<storage::DataLayout::BlockID>(
|
||||
storage::DataLayout::MLD_CELL_DURATIONS_0 + avoid_index);
|
||||
storage::DataLayout::MLD_CELL_DURATIONS_0 + exclude_index);
|
||||
|
||||
if (data_layout.GetBlockSize(weights_block_id) > 0)
|
||||
{
|
||||
@@ -1098,10 +1098,10 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
|
||||
public:
|
||||
ContiguousInternalMemoryAlgorithmDataFacade(
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator_, const std::size_t avoid_index)
|
||||
std::shared_ptr<ContiguousBlockAllocator> allocator_, const std::size_t exclude_index)
|
||||
: allocator(std::move(allocator_))
|
||||
{
|
||||
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), avoid_index);
|
||||
InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), exclude_index);
|
||||
}
|
||||
|
||||
const partition::MultiLevelPartitionView &GetMultiLevelPartition() const override
|
||||
@@ -1159,9 +1159,9 @@ class ContiguousInternalMemoryDataFacade<MLD> final
|
||||
private:
|
||||
public:
|
||||
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator,
|
||||
const std::size_t avoid_index)
|
||||
: ContiguousInternalMemoryDataFacadeBase(allocator, avoid_index),
|
||||
ContiguousInternalMemoryAlgorithmDataFacade<MLD>(allocator, avoid_index)
|
||||
const std::size_t exclude_index)
|
||||
: ContiguousInternalMemoryDataFacadeBase(allocator, exclude_index),
|
||||
ContiguousInternalMemoryAlgorithmDataFacade<MLD>(allocator, exclude_index)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class BaseDataFacade
|
||||
|
||||
virtual extractor::ClassData GetClassData(const NodeID id) const = 0;
|
||||
|
||||
virtual bool AvoidNode(const NodeID id) const = 0;
|
||||
virtual bool ExcludeNode(const NodeID id) const = 0;
|
||||
|
||||
virtual std::vector<std::string> GetClasses(const extractor::ClassData class_data) const = 0;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace engine
|
||||
// This class selects the right facade for
|
||||
template <template <typename A> class FacadeT, typename AlgorithmT> class DataFacadeFactory
|
||||
{
|
||||
static constexpr auto has_avoid_flags = routing_algorithms::HasAvoidFlags<AlgorithmT>{};
|
||||
static constexpr auto has_exclude_flags = routing_algorithms::HasExcludeFlags<AlgorithmT>{};
|
||||
|
||||
public:
|
||||
using Facade = FacadeT<AlgorithmT>;
|
||||
@@ -31,17 +31,17 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
|
||||
template <typename AllocatorT>
|
||||
DataFacadeFactory(std::shared_ptr<AllocatorT> allocator)
|
||||
: DataFacadeFactory(allocator, has_avoid_flags)
|
||||
: DataFacadeFactory(allocator, has_exclude_flags)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ParameterT> std::shared_ptr<const Facade> Get(const ParameterT ¶ms) const
|
||||
{
|
||||
return Get(params, has_avoid_flags);
|
||||
return Get(params, has_exclude_flags);
|
||||
}
|
||||
|
||||
private:
|
||||
// Algorithm with avoid flags
|
||||
// Algorithm with exclude flags
|
||||
template <typename AllocatorT>
|
||||
DataFacadeFactory(std::shared_ptr<AllocatorT> allocator, std::true_type)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
}
|
||||
}
|
||||
|
||||
// Algorithm without avoid flags
|
||||
// Algorithm without exclude flags
|
||||
template <typename AllocatorT>
|
||||
DataFacadeFactory(std::shared_ptr<AllocatorT> allocator, std::false_type)
|
||||
{
|
||||
@@ -75,10 +75,10 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
return facades[0];
|
||||
}
|
||||
|
||||
// Default for non-avoid flags: return only facade
|
||||
// Default for non-exclude flags: return only facade
|
||||
std::shared_ptr<const Facade> Get(const api::BaseParameters ¶ms, std::false_type) const
|
||||
{
|
||||
if (!params.avoid.empty())
|
||||
if (!params.exclude.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -86,7 +86,7 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
return facades[0];
|
||||
}
|
||||
|
||||
// TileParameters don't drive from BaseParameters and generally don't have use for avoid flags
|
||||
// TileParameters don't drive from BaseParameters and generally don't have use for exclude flags
|
||||
std::shared_ptr<const Facade> Get(const api::TileParameters &, std::true_type) const
|
||||
{
|
||||
return facades[0];
|
||||
@@ -95,11 +95,11 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
// Selection logic for finding the corresponding datafacade for the given parameters
|
||||
std::shared_ptr<const Facade> Get(const api::BaseParameters ¶ms, std::true_type) const
|
||||
{
|
||||
if (params.avoid.empty())
|
||||
if (params.exclude.empty())
|
||||
return facades[0];
|
||||
|
||||
extractor::ClassData mask = 0;
|
||||
for (const auto &name : params.avoid)
|
||||
for (const auto &name : params.exclude)
|
||||
{
|
||||
auto class_mask_iter = name_to_class.find(name);
|
||||
if (class_mask_iter == name_to_class.end())
|
||||
@@ -112,18 +112,19 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
|
||||
}
|
||||
}
|
||||
|
||||
auto avoid_iter = std::find(
|
||||
properties->avoidable_classes.begin(), properties->avoidable_classes.end(), mask);
|
||||
if (avoid_iter != properties->avoidable_classes.end())
|
||||
auto exclude_iter = std::find(
|
||||
properties->excludable_classes.begin(), properties->excludable_classes.end(), mask);
|
||||
if (exclude_iter != properties->excludable_classes.end())
|
||||
{
|
||||
auto avoid_index = std::distance(properties->avoidable_classes.begin(), avoid_iter);
|
||||
return facades[avoid_index];
|
||||
auto exclude_index =
|
||||
std::distance(properties->excludable_classes.begin(), exclude_iter);
|
||||
return facades[exclude_index];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::array<std::shared_ptr<const Facade>, extractor::MAX_AVOIDABLE_CLASSES> facades;
|
||||
std::array<std::shared_ptr<const Facade>, extractor::MAX_EXCLUDABLE_CLASSES> facades;
|
||||
std::unordered_map<std::string, extractor::ClassData> name_to_class;
|
||||
const extractor::ProfileProperties *properties = nullptr;
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate](const CandidateSegment &segment) {
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentAvoid(segment)),
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)),
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
},
|
||||
[this, max_distance, input_coordinate](const std::size_t,
|
||||
@@ -83,7 +83,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const CandidateSegment &segment) {
|
||||
auto use_direction =
|
||||
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentAvoid(segment)));
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)));
|
||||
use_direction =
|
||||
boolPairAnd(use_direction, CheckApproach(input_coordinate, segment, approach));
|
||||
return use_direction;
|
||||
@@ -111,7 +111,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const CandidateSegment &segment) {
|
||||
auto use_direction =
|
||||
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentAvoid(segment)));
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)));
|
||||
return boolPairAnd(use_direction,
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
},
|
||||
@@ -139,7 +139,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const CandidateSegment &segment) {
|
||||
auto use_direction =
|
||||
boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range),
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentAvoid(segment)));
|
||||
boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)));
|
||||
return boolPairAnd(use_direction,
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
},
|
||||
@@ -162,7 +162,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate](const CandidateSegment &segment) {
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentAvoid(segment)),
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)),
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
},
|
||||
[max_results](const std::size_t num_results, const CandidateSegment &) {
|
||||
@@ -183,7 +183,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate](const CandidateSegment &segment) {
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentAvoid(segment)),
|
||||
return boolPairAnd(boolPairAnd(HasValidEdge(segment), CheckSegmentExclude(segment)),
|
||||
CheckApproach(input_coordinate, segment, approach));
|
||||
},
|
||||
[this, max_distance, max_results, input_coordinate](const std::size_t num_results,
|
||||
@@ -212,7 +212,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
const auto valid_edges = HasValidEdge(segment);
|
||||
const auto admissible_segments = CheckSegmentAvoid(segment);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, admissible_segments);
|
||||
use_directions = boolPairAnd(use_directions, valid_edges);
|
||||
use_directions =
|
||||
@@ -259,7 +259,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
|
||||
const auto valid_edges = HasValidEdge(segment);
|
||||
const auto admissible_segments = CheckSegmentAvoid(segment);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, admissible_segments);
|
||||
use_directions = boolPairAnd(use_directions, valid_edges);
|
||||
use_directions =
|
||||
@@ -309,7 +309,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto use_segment =
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
const auto admissible_segments = CheckSegmentAvoid(segment);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
||||
|
||||
if (use_segment)
|
||||
@@ -367,7 +367,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto use_segment =
|
||||
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||
const auto admissible_segments = CheckSegmentAvoid(segment);
|
||||
const auto admissible_segments = CheckSegmentExclude(segment);
|
||||
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
||||
|
||||
if (use_segment)
|
||||
@@ -539,18 +539,18 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
max_distance;
|
||||
}
|
||||
|
||||
std::pair<bool, bool> CheckSegmentAvoid(const CandidateSegment &segment) const
|
||||
std::pair<bool, bool> CheckSegmentExclude(const CandidateSegment &segment) const
|
||||
{
|
||||
std::pair<bool, bool> valid = {true, true};
|
||||
|
||||
if (segment.data.forward_segment_id.enabled &&
|
||||
datafacade.AvoidNode(segment.data.forward_segment_id.id))
|
||||
datafacade.ExcludeNode(segment.data.forward_segment_id.id))
|
||||
{
|
||||
valid.first = false;
|
||||
}
|
||||
|
||||
if (segment.data.reverse_segment_id.enabled &&
|
||||
datafacade.AvoidNode(segment.data.reverse_segment_id.id))
|
||||
datafacade.ExcludeNode(segment.data.reverse_segment_id.id))
|
||||
{
|
||||
valid.second = false;
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ class BasePlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!algorithms.HasAvoidFlags() && !params.avoid.empty())
|
||||
if (!algorithms.HasExcludeFlags() && !params.exclude.empty())
|
||||
{
|
||||
Error("NotImplemented", "This algorithm does not support avoid flags.", result);
|
||||
Error("NotImplemented", "This algorithm does not support exclude flags.", result);
|
||||
return false;
|
||||
}
|
||||
if (algorithms.HasAvoidFlags() && !params.avoid.empty())
|
||||
if (algorithms.HasExcludeFlags() && !params.exclude.empty())
|
||||
{
|
||||
Error("InvalidValue", "Avoid flag combination is not supported.", result);
|
||||
Error("InvalidValue", "Exclude flag combination is not supported.", result);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class RoutingAlgorithmsInterface
|
||||
virtual bool HasMapMatching() const = 0;
|
||||
virtual bool HasManyToManySearch() const = 0;
|
||||
virtual bool HasGetTileTurns() const = 0;
|
||||
virtual bool HasAvoidFlags() const = 0;
|
||||
virtual bool HasExcludeFlags() const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
};
|
||||
|
||||
@@ -129,9 +129,9 @@ template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgo
|
||||
return routing_algorithms::HasGetTileTurns<Algorithm>::value;
|
||||
}
|
||||
|
||||
bool HasAvoidFlags() const final override
|
||||
bool HasExcludeFlags() const final override
|
||||
{
|
||||
return routing_algorithms::HasAvoidFlags<Algorithm>::value;
|
||||
return routing_algorithms::HasExcludeFlags<Algorithm>::value;
|
||||
}
|
||||
|
||||
bool IsValid() const final override { return static_cast<bool>(facade); }
|
||||
|
||||
@@ -148,7 +148,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
|
||||
const auto node = forward_heap.DeleteMin();
|
||||
const auto weight = forward_heap.GetKey(node);
|
||||
|
||||
BOOST_ASSERT(!facade.AvoidNode(node));
|
||||
BOOST_ASSERT(!facade.ExcludeNode(node));
|
||||
|
||||
// Upper bound for the path source -> target with
|
||||
// weight(source -> node) = weight weight(to -> target) ≤ reverse_weight
|
||||
@@ -238,7 +238,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
|
||||
{
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
|
||||
if (!facade.AvoidNode(to) &&
|
||||
if (!facade.ExcludeNode(to) &&
|
||||
checkParentCellRestriction(partition.GetCell(level + 1, to), args...))
|
||||
{
|
||||
BOOST_ASSERT_MSG(edge_data.weight > 0, "edge_weight invalid");
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace extractor
|
||||
using ClassData = std::uint8_t;
|
||||
constexpr ClassData INAVLID_CLASS_DATA = std::numeric_limits<ClassData>::max();
|
||||
static const std::uint8_t MAX_CLASS_INDEX = 8 - 1;
|
||||
static const std::uint8_t MAX_AVOIDABLE_CLASSES = 8;
|
||||
static const std::uint8_t MAX_EXCLUDABLE_CLASSES = 8;
|
||||
|
||||
inline bool isSubset(const ClassData lhs, const ClassData rhs) { return (lhs & rhs) == lhs; }
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ struct ProfileProperties
|
||||
use_turn_restrictions(false), left_hand_driving(false), fallback_to_duration(true),
|
||||
weight_name{"duration"}, call_tagless_node_function(true)
|
||||
{
|
||||
std::fill(avoidable_classes.begin(), avoidable_classes.end(), INAVLID_CLASS_DATA);
|
||||
std::fill(excludable_classes.begin(), excludable_classes.end(), INAVLID_CLASS_DATA);
|
||||
BOOST_ASSERT(weight_name[MAX_WEIGHT_NAME_LENGTH] == '\0');
|
||||
}
|
||||
|
||||
@@ -73,19 +73,19 @@ struct ProfileProperties
|
||||
return std::string(weight_name);
|
||||
}
|
||||
|
||||
// Mark this combination of classes as avoidable
|
||||
void SetAvoidableClasses(std::size_t index, ClassData classes)
|
||||
// Mark this combination of classes as excludable
|
||||
void SetExcludableClasses(std::size_t index, ClassData classes)
|
||||
{
|
||||
avoidable_classes[index] = classes;
|
||||
excludable_classes[index] = classes;
|
||||
}
|
||||
|
||||
// Check if this classes are avoidable
|
||||
boost::optional<std::size_t> ClassesAreAvoidable(ClassData classes) const
|
||||
// Check if this classes are excludable
|
||||
boost::optional<std::size_t> ClassesAreExcludable(ClassData classes) const
|
||||
{
|
||||
auto iter = std::find(avoidable_classes.begin(), avoidable_classes.end(), classes);
|
||||
if (iter != avoidable_classes.end())
|
||||
auto iter = std::find(excludable_classes.begin(), excludable_classes.end(), classes);
|
||||
if (iter != excludable_classes.end())
|
||||
{
|
||||
return std::distance(avoidable_classes.begin(), iter);
|
||||
return std::distance(excludable_classes.begin(), iter);
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -130,8 +130,8 @@ struct ProfileProperties
|
||||
char weight_name[MAX_WEIGHT_NAME_LENGTH + 1];
|
||||
//! stores the names of each class
|
||||
std::array<char[MAX_CLASS_NAME_LENGTH + 1], MAX_CLASS_INDEX + 1> class_names;
|
||||
//! stores the masks of avoidable class combinations
|
||||
std::array<ClassData, MAX_AVOIDABLE_CLASSES> avoidable_classes;
|
||||
//! stores the masks of excludable class combinations
|
||||
std::array<ClassData, MAX_EXCLUDABLE_CLASSES> excludable_classes;
|
||||
unsigned weight_precision = 1;
|
||||
bool force_split_edges = false;
|
||||
bool call_tagless_node_function = true;
|
||||
|
||||
@@ -52,7 +52,7 @@ class ScriptingEnvironment
|
||||
|
||||
virtual const ProfileProperties &GetProfileProperties() = 0;
|
||||
|
||||
virtual std::vector<std::vector<std::string>> GetAvoidableClasses() = 0;
|
||||
virtual std::vector<std::vector<std::string>> GetExcludableClasses() = 0;
|
||||
virtual std::vector<std::string> GetClassNames() = 0;
|
||||
virtual std::vector<std::string> GetNameSuffixList() = 0;
|
||||
virtual std::vector<std::string> GetRestrictions() = 0;
|
||||
|
||||
@@ -58,7 +58,7 @@ class Sol2ScriptingEnvironment final : public ScriptingEnvironment
|
||||
|
||||
const ProfileProperties &GetProfileProperties() override;
|
||||
|
||||
std::vector<std::vector<std::string>> GetAvoidableClasses() override;
|
||||
std::vector<std::vector<std::string>> GetExcludableClasses() override;
|
||||
std::vector<std::string> GetNameSuffixList() override;
|
||||
std::vector<std::string> GetClassNames() override;
|
||||
std::vector<std::string> GetRestrictions() override;
|
||||
|
||||
@@ -162,16 +162,16 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
(-approach_type %
|
||||
';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1];
|
||||
|
||||
avoid_rule = qi::lit("avoid=") >
|
||||
(qi::as_string[+qi::char_("a-zA-Z")] %
|
||||
',')[ph::bind(&engine::api::BaseParameters::avoid, qi::_r1) = qi::_1];
|
||||
exclude_rule = qi::lit("exclude=") >
|
||||
(qi::as_string[+qi::char_("a-zA-Z")] %
|
||||
',')[ph::bind(&engine::api::BaseParameters::exclude, qi::_r1) = qi::_1];
|
||||
|
||||
base_rule = radiuses_rule(qi::_r1) //
|
||||
| hints_rule(qi::_r1) //
|
||||
| bearings_rule(qi::_r1) //
|
||||
| generate_hints_rule(qi::_r1) //
|
||||
| approach_rule(qi::_r1) //
|
||||
| avoid_rule(qi::_r1);
|
||||
| exclude_rule(qi::_r1);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -185,7 +185,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
|
||||
qi::rule<Iterator, Signature> generate_hints_rule;
|
||||
qi::rule<Iterator, Signature> approach_rule;
|
||||
qi::rule<Iterator, Signature> avoid_rule;
|
||||
qi::rule<Iterator, Signature> exclude_rule;
|
||||
|
||||
qi::rule<Iterator, osrm::engine::Bearing()> bearing_rule;
|
||||
qi::rule<Iterator, osrm::util::Coordinate()> location_rule;
|
||||
|
||||
Reference in New Issue
Block a user