Format with clang-format 3.8
This commit is contained in:
@@ -96,7 +96,6 @@ inline double reverseBearing(const double bearing)
|
||||
return bearing - 180.;
|
||||
return bearing + 180;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef CAST_HPP
|
||||
#define CAST_HPP
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
|
||||
@@ -32,10 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <iosfwd> //for std::ostream
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -200,8 +200,10 @@ bool operator==(const FloatCoordinate lhs, const FloatCoordinate rhs);
|
||||
std::ostream &operator<<(std::ostream &out, const Coordinate coordinate);
|
||||
std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate);
|
||||
|
||||
inline Coordinate::Coordinate(const FloatCoordinate &other) : Coordinate(toFixed(other.lon), toFixed(other.lat)) {}
|
||||
|
||||
inline Coordinate::Coordinate(const FloatCoordinate &other)
|
||||
: Coordinate(toFixed(other.lon), toFixed(other.lat))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ const constexpr long double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD;
|
||||
const constexpr long double EARTH_RADIUS = 6372797.560856;
|
||||
}
|
||||
|
||||
|
||||
//! Takes the squared euclidean distance of the input coordinates. Does not return meters!
|
||||
std::uint64_t squaredEuclideanDistance(const Coordinate lhs, const Coordinate rhs);
|
||||
|
||||
@@ -32,8 +31,8 @@ double haversineDistance(const Coordinate first_coordinate, const Coordinate sec
|
||||
double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate);
|
||||
|
||||
inline std::pair<double, FloatCoordinate> projectPointOnSegment(const FloatCoordinate &source,
|
||||
const FloatCoordinate &target,
|
||||
const FloatCoordinate &coordinate)
|
||||
const FloatCoordinate &target,
|
||||
const FloatCoordinate &coordinate)
|
||||
{
|
||||
const FloatCoordinate slope_vector{target.lon - source.lon, target.lat - source.lat};
|
||||
const FloatCoordinate rel_coordinate{coordinate.lon - source.lon, coordinate.lat - source.lat};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef DIST_TABLE_WRAPPER_H
|
||||
#define DIST_TABLE_WRAPPER_H
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef FOR_EACH_PAIR_HPP
|
||||
#define FOR_EACH_PAIR_HPP
|
||||
|
||||
#include <numeric>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef GRAPH_LOADER_HPP
|
||||
#define GRAPH_LOADER_HPP
|
||||
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "extractor/node_based_edge.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/restriction.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
@@ -121,12 +121,13 @@ NodeID loadEdgesFromFile(std::istream &input_stream,
|
||||
|
||||
#ifndef NDEBUG
|
||||
SimpleLogger().Write() << "Validating loaded edges...";
|
||||
tbb::parallel_sort(edge_list.begin(), edge_list.end(),
|
||||
[](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs)
|
||||
{
|
||||
return (lhs.source < rhs.source) ||
|
||||
(lhs.source == rhs.source && lhs.target < rhs.target);
|
||||
});
|
||||
tbb::parallel_sort(
|
||||
edge_list.begin(),
|
||||
edge_list.end(),
|
||||
[](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs) {
|
||||
return (lhs.source < rhs.source) ||
|
||||
(lhs.source == rhs.source && lhs.target < rhs.target);
|
||||
});
|
||||
for (auto i = 1u; i < edge_list.size(); ++i)
|
||||
{
|
||||
const auto &edge = edge_list[i];
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
/* A set of tools required for guidance in both pre and post-processing */
|
||||
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "engine/guidance/route_step.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
@@ -33,10 +33,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <variant/variant.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef UTIL_JSON_DEEP_COMPARE_HPP
|
||||
#define UTIL_JSON_DEEP_COMPARE_HPP
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@@ -24,22 +24,26 @@ struct Comparator : mapbox::util::static_visitor<bool>
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const String &lhs, const String &rhs) const {
|
||||
bool is_same = lhs.value == rhs.value;
|
||||
if (!is_same)
|
||||
{
|
||||
reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value + "\")";
|
||||
}
|
||||
return is_same;
|
||||
bool operator()(const String &lhs, const String &rhs) const
|
||||
{
|
||||
bool is_same = lhs.value == rhs.value;
|
||||
if (!is_same)
|
||||
{
|
||||
reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value +
|
||||
"\")";
|
||||
}
|
||||
return is_same;
|
||||
}
|
||||
|
||||
bool operator()(const Number &lhs, const Number &rhs) const {
|
||||
bool is_same = lhs.value == rhs.value;
|
||||
if (!is_same)
|
||||
{
|
||||
reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + " (= " + std::to_string(rhs.value) + ")";
|
||||
}
|
||||
return is_same;
|
||||
bool operator()(const Number &lhs, const Number &rhs) const
|
||||
{
|
||||
bool is_same = lhs.value == rhs.value;
|
||||
if (!is_same)
|
||||
{
|
||||
reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + " (= " +
|
||||
std::to_string(rhs.value) + ")";
|
||||
}
|
||||
return is_same;
|
||||
}
|
||||
|
||||
bool operator()(const Object &lhs, const Object &rhs) const
|
||||
@@ -82,7 +86,8 @@ struct Comparator : mapbox::util::static_visitor<bool>
|
||||
const auto &rhs_child = rhs.values.find(key)->second;
|
||||
const auto &lhs_child = lhs.values.find(key)->second;
|
||||
auto is_same = mapbox::util::apply_visitor(
|
||||
Comparator(reason, lhs_path + "." + key, rhs_path + "." + key), lhs_child,
|
||||
Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
|
||||
lhs_child,
|
||||
rhs_child);
|
||||
if (!is_same)
|
||||
{
|
||||
@@ -103,10 +108,12 @@ struct Comparator : mapbox::util::static_visitor<bool>
|
||||
|
||||
for (auto i = 0UL; i < lhs.values.size(); ++i)
|
||||
{
|
||||
auto is_same = mapbox::util::apply_visitor(
|
||||
Comparator(reason, lhs_path + "[" + std::to_string(i) + "]",
|
||||
rhs_path + "[" + std::to_string(i) + "]"),
|
||||
lhs.values[i], rhs.values[i]);
|
||||
auto is_same =
|
||||
mapbox::util::apply_visitor(Comparator(reason,
|
||||
lhs_path + "[" + std::to_string(i) + "]",
|
||||
rhs_path + "[" + std::to_string(i) + "]"),
|
||||
lhs.values[i],
|
||||
rhs.values[i]);
|
||||
if (!is_same)
|
||||
{
|
||||
return false;
|
||||
@@ -148,8 +155,8 @@ struct Comparator : mapbox::util::static_visitor<bool>
|
||||
|
||||
inline bool compare(const Value &reference, const Value &result, std::string &reason)
|
||||
{
|
||||
return mapbox::util::apply_visitor(Comparator(reason, "reference", "result"), reference,
|
||||
result);
|
||||
return mapbox::util::apply_visitor(
|
||||
Comparator(reason, "reference", "result"), reference, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "osrm/json_container.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#define LUA_UTIL_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef MATRIX_GRAPH_WRAPPER_H
|
||||
#define MATRIX_GRAPH_WRAPPER_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
@@ -20,7 +20,9 @@ template <typename T> class MatrixGraphWrapper
|
||||
{
|
||||
public:
|
||||
MatrixGraphWrapper(std::vector<T> table, const std::size_t number_of_nodes)
|
||||
: table_(std::move(table)), number_of_nodes_(number_of_nodes){}
|
||||
: table_(std::move(table)), number_of_nodes_(number_of_nodes)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t GetNumberOfNodes() const { return number_of_nodes_; }
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef NODE_BASED_GRAPH_HPP
|
||||
#define NODE_BASED_GRAPH_HPP
|
||||
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "extractor/node_based_edge.hpp"
|
||||
#include "util/graph_utils.hpp"
|
||||
#include "extractor/guidance/classification_data.hpp"
|
||||
#include "extractor/node_based_edge.hpp"
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "util/graph_utils.hpp"
|
||||
|
||||
#include <tbb/parallel_sort.h>
|
||||
|
||||
@@ -68,9 +68,9 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes,
|
||||
const std::vector<extractor::NodeBasedEdge> &input_edge_list)
|
||||
{
|
||||
auto edges_list = directedEdgesFromCompressed<NodeBasedDynamicGraph::InputEdge>(
|
||||
input_edge_list, [](NodeBasedDynamicGraph::InputEdge &output_edge,
|
||||
const extractor::NodeBasedEdge &input_edge)
|
||||
{
|
||||
input_edge_list,
|
||||
[](NodeBasedDynamicGraph::InputEdge &output_edge,
|
||||
const extractor::NodeBasedEdge &input_edge) {
|
||||
output_edge.data.distance = static_cast<int>(input_edge.weight);
|
||||
BOOST_ASSERT(output_edge.data.distance > 0);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef PERCENT_HPP
|
||||
#define PERCENT_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
+10
-10
@@ -7,10 +7,10 @@
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -136,20 +136,20 @@ struct RectangleInt2D
|
||||
location, Coordinate(max_lon, location.lat));
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
min_dist =
|
||||
coordinate_calculation::squaredEuclideanDistance(location, Coordinate(max_lon, max_lat));
|
||||
min_dist = coordinate_calculation::squaredEuclideanDistance(
|
||||
location, Coordinate(max_lon, max_lat));
|
||||
break;
|
||||
case NORTH_WEST:
|
||||
min_dist =
|
||||
coordinate_calculation::squaredEuclideanDistance(location, Coordinate(min_lon, max_lat));
|
||||
min_dist = coordinate_calculation::squaredEuclideanDistance(
|
||||
location, Coordinate(min_lon, max_lat));
|
||||
break;
|
||||
case SOUTH_EAST:
|
||||
min_dist =
|
||||
coordinate_calculation::squaredEuclideanDistance(location, Coordinate(max_lon, min_lat));
|
||||
min_dist = coordinate_calculation::squaredEuclideanDistance(
|
||||
location, Coordinate(max_lon, min_lat));
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
min_dist =
|
||||
coordinate_calculation::squaredEuclideanDistance(location, Coordinate(min_lon, min_lat));
|
||||
min_dist = coordinate_calculation::squaredEuclideanDistance(
|
||||
location, Coordinate(min_lon, min_lat));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef STATIC_GRAPH_HPP
|
||||
#define STATIC_GRAPH_HPP
|
||||
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/percent.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#ifndef STATIC_RTREE_HPP
|
||||
#define STATIC_RTREE_HPP
|
||||
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/hilbert_value.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/rectangle.hpp"
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/web_mercator.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
@@ -52,9 +52,12 @@ class StaticRTree
|
||||
using EdgeData = EdgeDataT;
|
||||
using CoordinateList = CoordinateListT;
|
||||
|
||||
static_assert(LEAF_PAGE_SIZE >= sizeof(uint32_t) + sizeof(EdgeDataT), "LEAF_PAGE_SIZE is too small");
|
||||
static_assert(((LEAF_PAGE_SIZE - 1) & LEAF_PAGE_SIZE) == 0, "LEAF_PAGE_SIZE is not a power of 2");
|
||||
static constexpr std::uint32_t LEAF_NODE_SIZE = (LEAF_PAGE_SIZE - sizeof(uint32_t)) / sizeof(EdgeDataT);
|
||||
static_assert(LEAF_PAGE_SIZE >= sizeof(uint32_t) + sizeof(EdgeDataT),
|
||||
"LEAF_PAGE_SIZE is too small");
|
||||
static_assert(((LEAF_PAGE_SIZE - 1) & LEAF_PAGE_SIZE) == 0,
|
||||
"LEAF_PAGE_SIZE is not a power of 2");
|
||||
static constexpr std::uint32_t LEAF_NODE_SIZE =
|
||||
(LEAF_PAGE_SIZE - sizeof(uint32_t)) / sizeof(EdgeDataT);
|
||||
|
||||
struct CandidateSegment
|
||||
{
|
||||
@@ -76,7 +79,8 @@ class StaticRTree
|
||||
LeafNode() : object_count(0), objects() {}
|
||||
std::uint32_t object_count;
|
||||
std::array<EdgeDataT, LEAF_NODE_SIZE> objects;
|
||||
unsigned char leaf_page_padding[LEAF_PAGE_SIZE - sizeof(std::uint32_t) - sizeof(std::array<EdgeDataT, LEAF_NODE_SIZE>)];
|
||||
unsigned char leaf_page_padding[LEAF_PAGE_SIZE - sizeof(std::uint32_t) -
|
||||
sizeof(std::array<EdgeDataT, LEAF_NODE_SIZE>)];
|
||||
};
|
||||
static_assert(sizeof(LeafNode) == LEAF_PAGE_SIZE, "LeafNode size does not fit the page size");
|
||||
|
||||
@@ -100,8 +104,16 @@ class StaticRTree
|
||||
}
|
||||
};
|
||||
|
||||
struct TreeIndex { std::uint32_t index; };
|
||||
struct SegmentIndex { std::uint32_t index; std::uint32_t object; Coordinate fixed_projected_coordinate; };
|
||||
struct TreeIndex
|
||||
{
|
||||
std::uint32_t index;
|
||||
};
|
||||
struct SegmentIndex
|
||||
{
|
||||
std::uint32_t index;
|
||||
std::uint32_t object;
|
||||
Coordinate fixed_projected_coordinate;
|
||||
};
|
||||
using QueryNodeType = mapbox::util::variant<TreeIndex, SegmentIndex>;
|
||||
struct QueryCandidate
|
||||
{
|
||||
@@ -116,7 +128,7 @@ class StaticRTree
|
||||
};
|
||||
|
||||
typename ShM<TreeNode, UseSharedMemory>::vector m_search_tree;
|
||||
const CoordinateListT& m_coordinate_list;
|
||||
const CoordinateListT &m_coordinate_list;
|
||||
|
||||
boost::iostreams::mapped_file_source m_leaves_region;
|
||||
// read-only view of leaves
|
||||
@@ -132,7 +144,7 @@ class StaticRTree
|
||||
const std::string &tree_node_filename,
|
||||
const std::string &leaf_node_filename,
|
||||
const std::vector<CoordinateT> &coordinate_list)
|
||||
: m_coordinate_list(coordinate_list)
|
||||
: m_coordinate_list(coordinate_list)
|
||||
{
|
||||
const uint64_t element_count = input_data_vector.size();
|
||||
std::vector<WrappedInputElement> input_wrapper_vector(element_count);
|
||||
@@ -140,11 +152,11 @@ class StaticRTree
|
||||
// generate auxiliary vector of hilbert-values
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<uint64_t>(0, element_count),
|
||||
[&input_data_vector, &input_wrapper_vector,
|
||||
this](const tbb::blocked_range<uint64_t> &range)
|
||||
{
|
||||
[&input_data_vector, &input_wrapper_vector, this](
|
||||
const tbb::blocked_range<uint64_t> &range) {
|
||||
for (uint64_t element_counter = range.begin(), end = range.end();
|
||||
element_counter != end; ++element_counter)
|
||||
element_counter != end;
|
||||
++element_counter)
|
||||
{
|
||||
WrappedInputElement ¤t_wrapper = input_wrapper_vector[element_counter];
|
||||
current_wrapper.m_array_index = element_counter;
|
||||
@@ -194,8 +206,10 @@ class StaticRTree
|
||||
}
|
||||
|
||||
// generate tree node that resemble the objects in leaf and store it for next level
|
||||
InitializeMBRectangle(current_node.minimum_bounding_rectangle, current_leaf.objects,
|
||||
current_leaf.object_count, m_coordinate_list);
|
||||
InitializeMBRectangle(current_node.minimum_bounding_rectangle,
|
||||
current_leaf.objects,
|
||||
current_leaf.object_count,
|
||||
m_coordinate_list);
|
||||
current_node.child_is_on_disk = true;
|
||||
current_node.children[0] = tree_nodes_in_level.size();
|
||||
tree_nodes_in_level.emplace_back(current_node);
|
||||
@@ -217,7 +231,8 @@ class StaticRTree
|
||||
TreeNode parent_node;
|
||||
// pack BRANCHING_FACTOR elements into tree_nodes each
|
||||
for (std::uint32_t current_child_node_index = 0;
|
||||
BRANCHING_FACTOR > current_child_node_index; ++current_child_node_index)
|
||||
BRANCHING_FACTOR > current_child_node_index;
|
||||
++current_child_node_index)
|
||||
{
|
||||
if (processed_tree_nodes_in_level < tree_nodes_in_level.size())
|
||||
{
|
||||
@@ -247,21 +262,20 @@ class StaticRTree
|
||||
std::reverse(m_search_tree.begin(), m_search_tree.end());
|
||||
|
||||
std::uint32_t search_tree_size = m_search_tree.size();
|
||||
tbb::parallel_for(tbb::blocked_range<std::uint32_t>(0, search_tree_size),
|
||||
[this, &search_tree_size](const tbb::blocked_range<std::uint32_t> &range)
|
||||
{
|
||||
for (std::uint32_t i = range.begin(), end = range.end(); i != end;
|
||||
++i)
|
||||
{
|
||||
TreeNode ¤t_tree_node = this->m_search_tree[i];
|
||||
for (std::uint32_t j = 0; j < current_tree_node.child_count; ++j)
|
||||
{
|
||||
const std::uint32_t old_id = current_tree_node.children[j];
|
||||
const std::uint32_t new_id = search_tree_size - old_id - 1;
|
||||
current_tree_node.children[j] = new_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<std::uint32_t>(0, search_tree_size),
|
||||
[this, &search_tree_size](const tbb::blocked_range<std::uint32_t> &range) {
|
||||
for (std::uint32_t i = range.begin(), end = range.end(); i != end; ++i)
|
||||
{
|
||||
TreeNode ¤t_tree_node = this->m_search_tree[i];
|
||||
for (std::uint32_t j = 0; j < current_tree_node.child_count; ++j)
|
||||
{
|
||||
const std::uint32_t old_id = current_tree_node.children[j];
|
||||
const std::uint32_t new_id = search_tree_size - old_id - 1;
|
||||
current_tree_node.children[j] = new_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// open tree file
|
||||
boost::filesystem::ofstream tree_node_file(tree_node_filename, std::ios::binary);
|
||||
@@ -276,8 +290,8 @@ class StaticRTree
|
||||
|
||||
explicit StaticRTree(const boost::filesystem::path &node_file,
|
||||
const boost::filesystem::path &leaf_file,
|
||||
const CoordinateListT& coordinate_list)
|
||||
: m_coordinate_list(coordinate_list)
|
||||
const CoordinateListT &coordinate_list)
|
||||
: m_coordinate_list(coordinate_list)
|
||||
{
|
||||
// open tree node file and load into RAM.
|
||||
if (!boost::filesystem::exists(node_file))
|
||||
@@ -305,9 +319,8 @@ class StaticRTree
|
||||
explicit StaticRTree(TreeNode *tree_node_ptr,
|
||||
const uint64_t number_of_nodes,
|
||||
const boost::filesystem::path &leaf_file,
|
||||
const CoordinateListT& coordinate_list)
|
||||
: m_search_tree(tree_node_ptr, number_of_nodes)
|
||||
, m_coordinate_list(coordinate_list)
|
||||
const CoordinateListT &coordinate_list)
|
||||
: m_search_tree(tree_node_ptr, number_of_nodes), m_coordinate_list(coordinate_list)
|
||||
{
|
||||
MapLeafNodesFile(leaf_file);
|
||||
}
|
||||
@@ -315,12 +328,16 @@ class StaticRTree
|
||||
void MapLeafNodesFile(const boost::filesystem::path &leaf_file)
|
||||
{
|
||||
// open leaf node file and return a pointer to the mapped leaves data
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_leaves_region.open(leaf_file);
|
||||
std::size_t num_leaves = m_leaves_region.size() / sizeof(LeafNode);
|
||||
m_leaves.reset(reinterpret_cast<const LeafNode*>(m_leaves_region.data()), num_leaves);
|
||||
} catch (std::exception& exc) {
|
||||
throw exception(boost::str(boost::format("Leaf file %1% mapping failed: %2%") % leaf_file % exc.what()));
|
||||
m_leaves.reset(reinterpret_cast<const LeafNode *>(m_leaves_region.data()), num_leaves);
|
||||
}
|
||||
catch (std::exception &exc)
|
||||
{
|
||||
throw exception(boost::str(boost::format("Leaf file %1% mapping failed: %2%") %
|
||||
leaf_file % exc.what()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +346,8 @@ class StaticRTree
|
||||
std::vector<EdgeDataT> SearchInBox(const Rectangle &search_rectangle) const
|
||||
{
|
||||
const Rectangle projected_rectangle{
|
||||
search_rectangle.min_lon, search_rectangle.max_lon,
|
||||
search_rectangle.min_lon,
|
||||
search_rectangle.max_lon,
|
||||
toFixed(FloatLatitude{
|
||||
web_mercator::latToY(toFloating(FixedLatitude(search_rectangle.min_lat)))}),
|
||||
toFixed(FloatLatitude{
|
||||
@@ -346,7 +364,7 @@ class StaticRTree
|
||||
|
||||
if (current_tree_node.child_is_on_disk)
|
||||
{
|
||||
const LeafNode& current_leaf_node = m_leaves[current_tree_node.children[0]];
|
||||
const LeafNode ¤t_leaf_node = m_leaves[current_tree_node.children[0]];
|
||||
|
||||
for (const auto i : irange(0u, current_leaf_node.object_count))
|
||||
{
|
||||
@@ -391,23 +409,21 @@ class StaticRTree
|
||||
}
|
||||
|
||||
// Override filter and terminator for the desired behaviour.
|
||||
std::vector<EdgeDataT> Nearest(const Coordinate input_coordinate, const std::size_t max_results) const
|
||||
std::vector<EdgeDataT> Nearest(const Coordinate input_coordinate,
|
||||
const std::size_t max_results) const
|
||||
{
|
||||
return Nearest(input_coordinate,
|
||||
[](const CandidateSegment &)
|
||||
{
|
||||
return std::make_pair(true, true);
|
||||
},
|
||||
[max_results](const std::size_t num_results, const CandidateSegment &)
|
||||
{
|
||||
[](const CandidateSegment &) { return std::make_pair(true, true); },
|
||||
[max_results](const std::size_t num_results, const CandidateSegment &) {
|
||||
return num_results >= max_results;
|
||||
});
|
||||
}
|
||||
|
||||
// Override filter and terminator for the desired behaviour.
|
||||
template <typename FilterT, typename TerminationT>
|
||||
std::vector<EdgeDataT>
|
||||
Nearest(const Coordinate input_coordinate, const FilterT filter, const TerminationT terminate) const
|
||||
std::vector<EdgeDataT> Nearest(const Coordinate input_coordinate,
|
||||
const FilterT filter,
|
||||
const TerminationT terminate) const
|
||||
{
|
||||
std::vector<EdgeDataT> results;
|
||||
auto projected_coordinate = web_mercator::fromWGS84(input_coordinate);
|
||||
@@ -428,8 +444,10 @@ class StaticRTree
|
||||
m_search_tree[current_query_node.node.template get<TreeIndex>().index];
|
||||
if (current_tree_node.child_is_on_disk)
|
||||
{
|
||||
ExploreLeafNode(current_tree_node.children[0], fixed_projected_coordinate,
|
||||
projected_coordinate, traversal_queue);
|
||||
ExploreLeafNode(current_tree_node.children[0],
|
||||
fixed_projected_coordinate,
|
||||
projected_coordinate,
|
||||
traversal_queue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,10 +459,13 @@ class StaticRTree
|
||||
// inspecting an actual road segment
|
||||
const auto &segment_index = current_query_node.node.template get<SegmentIndex>();
|
||||
auto edge_data = m_leaves[segment_index.index].objects[segment_index.object];
|
||||
const auto ¤t_candidate = CandidateSegment{segment_index.fixed_projected_coordinate, edge_data};
|
||||
const auto ¤t_candidate =
|
||||
CandidateSegment{segment_index.fixed_projected_coordinate, edge_data};
|
||||
|
||||
// to allow returns of no-results if too restrictive filtering, this needs to be done here
|
||||
// even though performance would indicate that we want to stop after adding the first candidate
|
||||
// to allow returns of no-results if too restrictive filtering, this needs to be
|
||||
// done here
|
||||
// even though performance would indicate that we want to stop after adding the
|
||||
// first candidate
|
||||
if (terminate(results.size(), current_candidate))
|
||||
{
|
||||
traversal_queue = std::priority_queue<QueryCandidate>{};
|
||||
@@ -474,7 +495,7 @@ class StaticRTree
|
||||
const FloatCoordinate &projected_input_coordinate,
|
||||
QueueT &traversal_queue) const
|
||||
{
|
||||
const LeafNode& current_leaf_node = m_leaves[leaf_id];
|
||||
const LeafNode ¤t_leaf_node = m_leaves[leaf_id];
|
||||
|
||||
// current object represents a block on disk
|
||||
for (const auto i : irange(0u, current_leaf_node.object_count))
|
||||
@@ -485,14 +506,15 @@ class StaticRTree
|
||||
|
||||
FloatCoordinate projected_nearest;
|
||||
std::tie(std::ignore, projected_nearest) =
|
||||
coordinate_calculation::projectPointOnSegment(projected_u, projected_v,
|
||||
projected_input_coordinate);
|
||||
coordinate_calculation::projectPointOnSegment(
|
||||
projected_u, projected_v, projected_input_coordinate);
|
||||
|
||||
const auto squared_distance = coordinate_calculation::squaredEuclideanDistance(
|
||||
projected_input_coordinate_fixed, projected_nearest);
|
||||
// distance must be non-negative
|
||||
BOOST_ASSERT(0. <= squared_distance);
|
||||
traversal_queue.push(QueryCandidate{squared_distance, SegmentIndex{leaf_id, i, Coordinate{projected_nearest}}});
|
||||
traversal_queue.push(QueryCandidate{
|
||||
squared_distance, SegmentIndex{leaf_id, i, Coordinate{projected_nearest}}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,8 +530,8 @@ class StaticRTree
|
||||
const auto &child_rectangle = child_tree_node.minimum_bounding_rectangle;
|
||||
const auto squared_lower_bound_to_element =
|
||||
child_rectangle.GetMinSquaredDist(fixed_projected_input_coordinate);
|
||||
traversal_queue.push(
|
||||
QueryCandidate{squared_lower_bound_to_element, TreeIndex{static_cast<std::uint32_t>(child_id)}});
|
||||
traversal_queue.push(QueryCandidate{squared_lower_bound_to_element,
|
||||
TreeIndex{static_cast<std::uint32_t>(child_id)}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ template <int length, int precision> char *printInt(char *buffer, int value)
|
||||
static_assert(length > 0, "length must be positive");
|
||||
static_assert(precision > 0, "precision must be positive");
|
||||
|
||||
const bool minus = [&value]
|
||||
{
|
||||
const bool minus = [&value] {
|
||||
if (value >= 0)
|
||||
{
|
||||
value = -value;
|
||||
|
||||
@@ -28,9 +28,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef STRONG_TYPEDEF_HPP
|
||||
#define STRONG_TYPEDEF_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
@@ -358,13 +358,12 @@ constexpr unsigned short atan_table[4096] = {
|
||||
0xffe0, 0xffea, 0xfff4, 0xffff};
|
||||
|
||||
// max value is pi/4
|
||||
#ifdef _MSC_VER //TODO: remove as soon as boost allows C++14 features with Visual Studio
|
||||
#ifdef _MSC_VER // TODO: remove as soon as boost allows C++14 features with Visual Studio
|
||||
const constexpr double SCALING_FACTOR = 4. / M_PI * 0xFFFF;
|
||||
#else
|
||||
const constexpr double SCALING_FACTOR = 4. / boost::math::constants::pi<double>() * 0xFFFF;
|
||||
#endif
|
||||
|
||||
|
||||
inline double atan2_lookup(double y, double x)
|
||||
{
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ const constexpr std::uint32_t VARIANT_TYPE_DOUBLE = 3;
|
||||
// Vector tiles are 4096 virtual pixels on each side
|
||||
const constexpr double EXTENT = 4096.0;
|
||||
const constexpr double BUFFER = 128.0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,12 @@ inline double latToY(const FloatLatitude latitude)
|
||||
return clamped_y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr double horner(double, T an) { return an; }
|
||||
template <typename T> constexpr double horner(double, T an) { return an; }
|
||||
|
||||
template<typename T, typename... U>
|
||||
constexpr double horner(double x, T an, U ...a) { return horner(x, a...) * x + an; }
|
||||
template <typename T, typename... U> constexpr double horner(double x, T an, U... a)
|
||||
{
|
||||
return horner(x, a...) * x + an;
|
||||
}
|
||||
|
||||
inline double latToYapprox(const FloatLatitude latitude)
|
||||
{
|
||||
@@ -59,17 +60,35 @@ inline double latToYapprox(const FloatLatitude latitude)
|
||||
return latToY(latitude);
|
||||
|
||||
// Approximate the inverse Gudermannian function with the Padé approximant [11/11]: deg → deg
|
||||
// Coefficients are computed for the argument range [-70°,70°] by Remez algorithm |err|_∞=3.387e-12
|
||||
// Coefficients are computed for the argument range [-70°,70°] by Remez algorithm
|
||||
// |err|_∞=3.387e-12
|
||||
const auto x = static_cast<double>(latitude);
|
||||
return
|
||||
horner(x, 0.00000000000000000000000000e+00, 1.00000000000089108431373566e+00, 2.34439410386997223035693483e-06,
|
||||
-3.21291701673364717170998957e-04, -6.62778508496089940141103135e-10, 3.68188055470304769936079078e-08,
|
||||
6.31192702320492485752941578e-14, -1.77274453235716299127325443e-12, -2.24563810831776747318521450e-18,
|
||||
3.13524754818073129982475171e-17, 2.09014225025314211415458228e-23, -9.82938075991732185095509716e-23) /
|
||||
horner(x, 1.00000000000000000000000000e+00, 2.34439410398970701719081061e-06, -3.72061271627251952928813333e-04,
|
||||
-7.81802389685429267252612620e-10, 5.18418724186576447072888605e-08, 9.37468561198098681003717477e-14,
|
||||
-3.30833288607921773936702558e-12, -4.78446279888774903983338274e-18, 9.32999229169156878168234191e-17,
|
||||
9.17695141954265959600965170e-23, -8.72130728982012387640166055e-22, -3.23083224835967391884404730e-28);
|
||||
return horner(x,
|
||||
0.00000000000000000000000000e+00,
|
||||
1.00000000000089108431373566e+00,
|
||||
2.34439410386997223035693483e-06,
|
||||
-3.21291701673364717170998957e-04,
|
||||
-6.62778508496089940141103135e-10,
|
||||
3.68188055470304769936079078e-08,
|
||||
6.31192702320492485752941578e-14,
|
||||
-1.77274453235716299127325443e-12,
|
||||
-2.24563810831776747318521450e-18,
|
||||
3.13524754818073129982475171e-17,
|
||||
2.09014225025314211415458228e-23,
|
||||
-9.82938075991732185095509716e-23) /
|
||||
horner(x,
|
||||
1.00000000000000000000000000e+00,
|
||||
2.34439410398970701719081061e-06,
|
||||
-3.72061271627251952928813333e-04,
|
||||
-7.81802389685429267252612620e-10,
|
||||
5.18418724186576447072888605e-08,
|
||||
9.37468561198098681003717477e-14,
|
||||
-3.30833288607921773936702558e-12,
|
||||
-4.78446279888774903983338274e-18,
|
||||
9.32999229169156878168234191e-17,
|
||||
9.17695141954265959600965170e-23,
|
||||
-8.72130728982012387640166055e-22,
|
||||
-3.23083224835967391884404730e-28);
|
||||
}
|
||||
|
||||
inline FloatLatitude clamp(const FloatLatitude lat)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
|
||||
Reference in New Issue
Block a user