From d09f5c0e3a76e553993dde15d3a89ab0ad94bc35 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 16 Aug 2017 20:21:19 +0000 Subject: [PATCH] Avoid -> Exclude --- .../{avoid.feature => exclude.feature} | 36 +++++++-------- include/engine/algorithm.hpp | 4 +- include/engine/api/base_parameters.hpp | 6 +-- .../contiguous_internalmem_datafacade.hpp | 46 +++++++++---------- include/engine/datafacade/datafacade_base.hpp | 2 +- include/engine/datafacade_factory.hpp | 33 ++++++------- include/engine/geospatial_query.hpp | 26 +++++------ include/engine/plugins/plugin_base.hpp | 8 ++-- include/engine/routing_algorithms.hpp | 6 +-- .../routing_algorithms/routing_base_mld.hpp | 4 +- include/extractor/class_data.hpp | 2 +- include/extractor/profile_properties.hpp | 22 ++++----- include/extractor/scripting_environment.hpp | 2 +- .../extractor/scripting_environment_lua.hpp | 2 +- .../server/api/base_parameters_grammar.hpp | 10 ++-- profiles/car.lua | 4 +- profiles/testbot.lua | 4 +- src/customize/customizer.cpp | 10 ++-- .../alternative_path_mld.cpp | 4 +- .../routing_algorithms/many_to_many.cpp | 8 ++-- src/extractor/extractor.cpp | 26 +++++------ src/extractor/scripting_environment_lua.cpp | 4 +- unit_tests/customizer/cell_customization.cpp | 4 +- unit_tests/engine/offline_facade.cpp | 2 +- unit_tests/mocks/mock_datafacade.hpp | 2 +- .../mocks/mock_scripting_environment.hpp | 2 +- unit_tests/server/parameters_parser.cpp | 8 ++-- 27 files changed, 145 insertions(+), 142 deletions(-) rename features/testbot/{avoid.feature => exclude.feature} (59%) diff --git a/features/testbot/avoid.feature b/features/testbot/exclude.feature similarity index 59% rename from features/testbot/avoid.feature rename to features/testbot/exclude.feature index 1e12b4e17..a780ab307 100644 --- a/features/testbot/avoid.feature +++ b/features/testbot/exclude.feature @@ -1,5 +1,5 @@ -@routing @testbot @avoid @mld -Feature: Testbot - Avoid flags +@routing @testbot @exclude @mld +Feature: Testbot - Exclude flags Background: Given the profile "testbot" Given the node map @@ -10,17 +10,17 @@ Feature: Testbot - Avoid flags """ And the ways - | nodes | highway | toll | # | - | ab | primary | | always drivable | - | bc | motorway | | not drivable for avoid=motorway and avoid=motorway,toll | - | be | primary | yes | not drivable for avoid=toll and avoid=motorway,toll | - | ef | primary | yes | not drivable for avoid=toll and avoid=motorway,toll | - | fc | primary | yes | not drivable for avoid=toll and avoid=motorway,toll | - | cd | motorway | yes | not drivable for avoid=motorway avoid=toll and avoid=motorway,toll | - | fg | primary | | always drivable | - | gd | primary | | always drivable | + | nodes | highway | toll | # | + | ab | primary | | always drivable | + | bc | motorway | | not drivable for exclude=motorway and exclude=motorway,toll | + | be | primary | yes | not drivable for exclude=toll and exclude=motorway,toll | + | ef | primary | yes | not drivable for exclude=toll and exclude=motorway,toll | + | fc | primary | yes | not drivable for exclude=toll and exclude=motorway,toll | + | cd | motorway | yes | not drivable for exclude=motorway exclude=toll and exclude=motorway,toll | + | fg | primary | | always drivable | + | gd | primary | | always drivable | - Scenario: Testbot - avoid nothing + Scenario: Testbot - exclude nothing When I route I should get | from | to | route | | a | d | ab,bc,cd,cd | @@ -28,9 +28,9 @@ Feature: Testbot - Avoid flags | a | c | ab,bc,bc | | a | f | ab,be,ef,ef | - Scenario: Testbot - avoid motorway + Scenario: Testbot - exclude motorway Given the query options - | avoid | motorway | + | exclude | motorway | When I route I should get | from | to | route | @@ -39,9 +39,9 @@ Feature: Testbot - Avoid flags | a | c | ab,be,ef,fc,fc | | a | f | ab,be,ef,ef | - Scenario: Testbot - avoid toll + Scenario: Testbot - exclude toll Given the query options - | avoid | toll | + | exclude | toll | When I route I should get | from | to | route | @@ -51,9 +51,9 @@ Feature: Testbot - Avoid flags | a | f | | | f | d | fg,gd,gd | - Scenario: Testbot - avoid motorway and toll + Scenario: Testbot - exclude motorway and toll Given the query options - | avoid | motorway,toll | + | exclude | motorway,toll | When I route I should get | from | to | route | diff --git a/include/engine/algorithm.hpp b/include/engine/algorithm.hpp index 8e8f8481c..f6a4bc65a 100644 --- a/include/engine/algorithm.hpp +++ b/include/engine/algorithm.hpp @@ -56,7 +56,7 @@ template struct HasManyToManySearch final : std::false_typ template struct HasGetTileTurns final : std::false_type { }; -template struct HasAvoidFlags final : std::false_type +template struct HasExcludeFlags final : std::false_type { }; @@ -114,7 +114,7 @@ template <> struct HasManyToManySearch final : std::true_type template <> struct HasGetTileTurns final : std::true_type { }; -template <> struct HasAvoidFlags final : std::true_type +template <> struct HasExcludeFlags final : std::true_type { }; } diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index dc1ffa0b1..d63c58e5c 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -68,7 +68,7 @@ struct BaseParameters std::vector> radiuses; std::vector> bearings; std::vector> approaches; - std::vector avoid; + std::vector 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> bearings_ = {}, std::vector> approaches_ = {}, bool generate_hints_ = true, - std::vector avoid = {}) + std::vector 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_) { } diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index e4fb05ed7..8ab1226bc 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -212,7 +212,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade using SharedGeospatialQuery = GeospatialQuery; 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( 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 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 GetClasses(const extractor::ClassData class_data) const override final @@ -940,8 +940,8 @@ class ContiguousInternalMemoryDataFacade { public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, - const std::size_t avoid_index) - : ContiguousInternalMemoryDataFacadeBase(allocator, avoid_index), + const std::size_t exclude_index) + : ContiguousInternalMemoryDataFacadeBase(allocator, exclude_index), ContiguousInternalMemoryAlgorithmDataFacade(allocator) { @@ -955,8 +955,8 @@ class ContiguousInternalMemoryDataFacade final { public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, - const std::size_t avoid_index) - : ContiguousInternalMemoryDataFacade(allocator, avoid_index), + const std::size_t exclude_index) + : ContiguousInternalMemoryDataFacade(allocator, exclude_index), ContiguousInternalMemoryAlgorithmDataFacade(allocator) { @@ -977,15 +977,15 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade : 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 : public Algo } const auto weights_block_id = static_cast( - 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::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 : public Algo public: ContiguousInternalMemoryAlgorithmDataFacade( - std::shared_ptr allocator_, const std::size_t avoid_index) + std::shared_ptr 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 final private: public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, - const std::size_t avoid_index) - : ContiguousInternalMemoryDataFacadeBase(allocator, avoid_index), - ContiguousInternalMemoryAlgorithmDataFacade(allocator, avoid_index) + const std::size_t exclude_index) + : ContiguousInternalMemoryDataFacadeBase(allocator, exclude_index), + ContiguousInternalMemoryAlgorithmDataFacade(allocator, exclude_index) { } diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index 3551259ac..1011d853e 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -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 GetClasses(const extractor::ClassData class_data) const = 0; diff --git a/include/engine/datafacade_factory.hpp b/include/engine/datafacade_factory.hpp index 19984b0d7..92efcf7ee 100644 --- a/include/engine/datafacade_factory.hpp +++ b/include/engine/datafacade_factory.hpp @@ -23,7 +23,7 @@ namespace engine // This class selects the right facade for template