From bc8617a9f44dd194467bd924fbfbaa9840f462a9 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Fri, 18 Aug 2017 22:00:18 +0000 Subject: [PATCH] Fix remaining PR comments --- include/customizer/cell_customizer.hpp | 4 ++-- include/partition/cell_storage.hpp | 4 ++-- profiles/testbot.lua | 8 ++++---- src/customize/customizer.cpp | 14 ++++++++------ src/extractor/extractor.cpp | 3 +-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/customizer/cell_customizer.hpp b/include/customizer/cell_customizer.hpp index 2b0b840b1..0b9a7c020 100644 --- a/include/customizer/cell_customizer.hpp +++ b/include/customizer/cell_customizer.hpp @@ -37,7 +37,7 @@ class CellCustomizer const std::vector &allowed_nodes, CellMetric &metric, LevelID level, - CellID id) + CellID id) const { auto cell = cells.GetCell(metric, level, id); auto destinations = cell.GetDestinationNodes(); @@ -98,7 +98,7 @@ class CellCustomizer void Customize(const GraphT &graph, const partition::CellStorage &cells, const std::vector &allowed_nodes, - CellMetric &metric) + CellMetric &metric) const { Heap heap_exemplar(graph.GetNumberOfNodes()); HeapPtr heaps(heap_exemplar); diff --git a/include/partition/cell_storage.hpp b/include/partition/cell_storage.hpp index 529a0353b..12b209627 100644 --- a/include/partition/cell_storage.hpp +++ b/include/partition/cell_storage.hpp @@ -338,8 +338,8 @@ template class CellStorageImpl } const auto &last_cell = cells.back(); - ValueOffset total_size = cells.back().value_offset + - last_cell.num_source_nodes * last_cell.num_destination_nodes; + ValueOffset total_size = + last_cell.value_offset + last_cell.num_source_nodes * last_cell.num_destination_nodes; metric.weights.resize(total_size + 1, INVALID_EDGE_WEIGHT); metric.durations.resize(total_size + 1, MAXIMAL_EDGE_DURATION); diff --git a/profiles/testbot.lua b/profiles/testbot.lua index 079098256..57292bbd8 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -19,12 +19,12 @@ function setup() use_turn_restrictions = true }, - classes = {[0] = "motorway", [1] = "toll", [2] = "TooWords2"}, + classes = {"motorway", "toll", "TooWords2"}, excludable = { - [1] = {["motorway"] = true}, - [2] = {["toll"] = true}, - [3] = {["motorway"] = true, ["toll"] = true} + {["motorway"] = true}, + {["toll"] = true}, + {["motorway"] = true, ["toll"] = true} }, default_speed = 24, diff --git a/src/customize/customizer.cpp b/src/customize/customizer.cpp index a20c49839..311cf580b 100644 --- a/src/customize/customizer.cpp +++ b/src/customize/customizer.cpp @@ -22,6 +22,8 @@ namespace osrm namespace customizer { +namespace +{ template void CellStorageStatistics(const Graph &graph, const Partition &partition, @@ -113,12 +115,11 @@ excludeFlagsToNodeFilter(const MultiLevelEdgeBasedGraph &graph, return filters; } -std::vector filterToMetrics(const MultiLevelEdgeBasedGraph &graph, - const partition::CellStorage &storage, - const partition::MultiLevelPartition &mlp, - const std::vector> &node_filters) +std::vector customizeFilteredMetrics(const MultiLevelEdgeBasedGraph &graph, + const partition::CellStorage &storage, + const CellCustomizer &customizer, + const std::vector> &node_filters) { - CellCustomizer customizer(mlp); std::vector metrics; for (auto filter : node_filters) @@ -130,6 +131,7 @@ std::vector filterToMetrics(const MultiLevelEdgeBasedGraph &graph, return metrics; } +} int Customizer::Run(const CustomizationConfig &config) { @@ -156,7 +158,7 @@ int Customizer::Run(const CustomizationConfig &config) TIMER_START(cell_customize); auto filter = excludeFlagsToNodeFilter(graph, node_data, properties); - auto metrics = filterToMetrics(graph, storage, mlp, filter); + auto metrics = customizeFilteredMetrics(graph, storage, CellCustomizer{mlp}, filter); TIMER_STOP(cell_customize); util::Log() << "Cells customization took " << TIMER_SEC(cell_customize) << " seconds"; diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index b12c6e9a0..8e71af86d 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -82,8 +82,7 @@ void SetClassNames(const std::vector &class_names, { if (!isValidClassName(name)) { - throw util::exception("Invalid class name " + name + - " only [a-Z0-9] allowed."); + throw util::exception("Invalid class name " + name + " only [a-Z0-9] allowed."); } auto iter = classes_map.find(name);