From b20b7e65bf2f8bdf50d8c0462f20bed499aebb58 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 27 Jan 2015 17:44:46 +0100 Subject: [PATCH] renamed: Util/* -> util/* --- CMakeLists.txt | 24 +- Library/OSRM_impl.cpp | 6 +- Server/Http/Reply.cpp | 2 +- Server/data_structures/datafacade_base.hpp | 6 +- .../data_structures/internal_datafacade.hpp | 6 +- Server/data_structures/shared_datafacade.hpp | 6 +- Server/data_structures/shared_datatype.hpp | 4 +- Server/http/reply.cpp | 2 +- Util/cast.hpp | 11 +- Util/compute_angle.cpp | 2 +- Util/container.hpp | 13 +- Util/fingerprint.hpp | 2 +- Util/git_sha.hpp | 2 +- Util/graph_loader.hpp | 44 +- Util/json_renderer.hpp | 3 +- Util/make_unique.hpp | 2 +- Util/osrm_exception.cpp | 20 +- Util/range_algorithms.hpp | 12 +- Util/simple_logger.cpp | 10 +- Util/std_hash.hpp | 23 +- Util/timing_util.hpp | 34 +- Util/xml_renderer.hpp | 25 +- algorithms/douglas_peucker.cpp | 2 +- algorithms/object_encoder.hpp | 13 +- algorithms/tiny_components.hpp | 52 +- benchmarks/static_rtree.cpp | 4 +- cmake/FingerPrint-Config.cmake | 6 +- contractor/contractor.hpp | 200 ++++---- contractor/edge_based_graph_factory.cpp | 10 +- contractor/geometry_compressor.cpp | 38 +- contractor/processing_chain.cpp | 18 +- data_structures/coordinate.cpp | 4 +- data_structures/coordinate_calculation.cpp | 4 +- data_structures/deallocating_vector.hpp | 20 +- data_structures/dynamic_graph.hpp | 19 +- data_structures/node_based_graph.hpp | 48 +- data_structures/range_table.hpp | 81 ++-- data_structures/restriction_map.hpp | 30 +- data_structures/shared_memory_factory.hpp | 53 ++- data_structures/static_graph.hpp | 13 +- data_structures/static_rtree.hpp | 408 ++++++++-------- datastore.cpp | 10 +- descriptors/description_factory.cpp | 4 +- descriptors/gpx_descriptor.hpp | 2 +- descriptors/json_descriptor.hpp | 12 +- extract.cpp | 2 +- extractor/extraction_containers.cpp | 6 +- extractor/extraction_containers.hpp | 2 +- extractor/extraction_helper_functions.hpp | 4 +- extractor/extractor.cpp | 8 +- extractor/extractor_callbacks.cpp | 6 +- extractor/extractor_options.cpp | 6 +- extractor/restriction_parser.cpp | 6 +- extractor/scripting_environment.cpp | 6 +- library/osrm_impl.cpp | 6 +- plugins/distance_table.hpp | 29 +- plugins/hello_world.hpp | 18 +- plugins/locate.hpp | 15 +- plugins/nearest.hpp | 18 +- plugins/timestamp.hpp | 4 +- plugins/viaroute.hpp | 10 +- routed.cpp | 6 +- routing_algorithms/alternative_path.hpp | 138 ++---- routing_algorithms/routing_base.hpp | 46 +- routing_algorithms/shortest_path.hpp | 119 +++-- server/Http/Reply.cpp | 2 +- server/data_structures/datafacade_base.hpp | 6 +- .../data_structures/internal_datafacade.hpp | 6 +- server/data_structures/shared_datafacade.hpp | 6 +- server/data_structures/shared_datatype.hpp | 4 +- server/http/reply.cpp | 2 +- server/request_handler.cpp | 8 +- server/server.hpp | 6 +- tools/check-hsgr.cpp | 20 +- tools/components.cpp | 63 ++- tools/io-benchmark.cpp | 22 +- tools/simpleclient.cpp | 8 +- tools/springclean.cpp | 4 +- tools/unlock_all_mutexes.cpp | 4 +- unit_tests/data_structures/static_rtree.cpp | 2 +- util/bearing.cpp | 65 +++ util/bearing.hpp | 38 ++ util/boost_filesystem_2_fix.hpp | 144 ++++++ util/cast.hpp | 185 ++++++++ util/compute_angle.cpp | 54 +++ util/compute_angle.hpp | 42 ++ util/container.hpp | 85 ++++ util/datastore_options.hpp | 273 +++++++++++ util/fingerprint.cpp.in | 103 ++++ util/fingerprint.hpp | 59 +++ util/floating_point.hpp | 44 ++ util/git_sha.cpp.in | 31 ++ util/git_sha.hpp | 33 ++ util/graph_loader.hpp | 320 +++++++++++++ util/ini_file.hpp | 51 ++ util/integer_range.hpp | 70 +++ util/iterator_range.hpp | 72 +++ util/json_renderer.hpp | 184 +++++++ util/lua_util.hpp | 66 +++ util/make_unique.hpp | 57 +++ util/mercator.cpp | 40 ++ util/mercator.hpp | 38 ++ util/osrm_exception.cpp | 43 ++ util/osrm_exception.hpp | 51 ++ util/range_algorithms.hpp | 42 ++ util/routed_options.hpp | 277 +++++++++++ util/simple_logger.cpp | 135 ++++++ util/simple_logger.hpp | 74 +++ util/std_hash.hpp | 72 +++ util/string_util.hpp | 150 ++++++ util/timing_util.hpp | 90 ++++ util/trigonometry_table.hpp | 448 ++++++++++++++++++ util/xml_renderer.hpp | 140 ++++++ 113 files changed, 4533 insertions(+), 971 deletions(-) create mode 100644 util/bearing.cpp create mode 100644 util/bearing.hpp create mode 100644 util/boost_filesystem_2_fix.hpp create mode 100644 util/cast.hpp create mode 100644 util/compute_angle.cpp create mode 100644 util/compute_angle.hpp create mode 100644 util/container.hpp create mode 100644 util/datastore_options.hpp create mode 100644 util/fingerprint.cpp.in create mode 100644 util/fingerprint.hpp create mode 100644 util/floating_point.hpp create mode 100644 util/git_sha.cpp.in create mode 100644 util/git_sha.hpp create mode 100644 util/graph_loader.hpp create mode 100644 util/ini_file.hpp create mode 100644 util/integer_range.hpp create mode 100644 util/iterator_range.hpp create mode 100644 util/json_renderer.hpp create mode 100644 util/lua_util.hpp create mode 100644 util/make_unique.hpp create mode 100644 util/mercator.cpp create mode 100644 util/mercator.hpp create mode 100644 util/osrm_exception.cpp create mode 100644 util/osrm_exception.hpp create mode 100644 util/range_algorithms.hpp create mode 100644 util/routed_options.hpp create mode 100644 util/simple_logger.cpp create mode 100644 util/simple_logger.hpp create mode 100644 util/std_hash.hpp create mode 100644 util/string_util.hpp create mode 100644 util/timing_util.hpp create mode 100644 util/trigonometry_table.hpp create mode 100644 util/xml_renderer.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ccb2632bc..f01518799 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,44 +34,44 @@ include_directories(${CMAKE_SOURCE_DIR}/include/) include_directories(${CMAKE_SOURCE_DIR}/third_party/) include_directories(${CMAKE_SOURCE_DIR}/third_party/libosmium/include/) -add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/Util/fingerprint.cpp fingerprint.cpp.alwaysbuild +add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/util/fingerprint.cpp fingerprint.cpp.alwaysbuild COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FingerPrint-Config.cmake DEPENDS - ${CMAKE_SOURCE_DIR}/Util/fingerprint.cpp.in + ${CMAKE_SOURCE_DIR}/util/fingerprint.cpp.in COMMENT "Configuring fingerprint.cpp" VERBATIM) -add_custom_target(FingerPrintConfigure DEPENDS ${CMAKE_SOURCE_DIR}/Util/fingerprint.cpp) +add_custom_target(FingerPrintConfigure DEPENDS ${CMAKE_SOURCE_DIR}/util/fingerprint.cpp) add_custom_target(tests DEPENDS datastructure-tests algorithm-tests) add_custom_target(benchmarks DEPENDS rtree-bench) set(BOOST_COMPONENTS date_time filesystem iostreams program_options regex system thread unit_test_framework) configure_file( - ${CMAKE_SOURCE_DIR}/Util/git_sha.cpp.in - ${CMAKE_SOURCE_DIR}/Util/git_sha.cpp + ${CMAKE_SOURCE_DIR}/util/git_sha.cpp.in + ${CMAKE_SOURCE_DIR}/util/git_sha.cpp ) file(GLOB ExtractorGlob extractor/*.cpp) file(GLOB ImporterGlob data_structures/import_edge.cpp data_structures/external_memory_node.cpp) add_library(IMPORT OBJECT ${ImporterGlob}) -add_library(LOGGER OBJECT Util/simple_logger.cpp) +add_library(LOGGER OBJECT util/simple_logger.cpp) add_library(PHANTOMNODE OBJECT data_structures/phantom_node.cpp) -add_library(EXCEPTION OBJECT Util/osrm_exception.cpp) -add_library(MERCATOR OBJECT Util/mercator.cpp) +add_library(EXCEPTION OBJECT util/osrm_exception.cpp) +add_library(MERCATOR OBJECT util/mercator.cpp) set(ExtractorSources extract.cpp ${ExtractorGlob}) add_executable(osrm-extract ${ExtractorSources} $ $ $ $ $ $ $) add_library(RESTRICTION OBJECT data_structures/restriction_map.cpp) -file(GLOB PrepareGlob contractor/*.cpp data_structures/hilbert_value.cpp Util/compute_angle.cpp {RestrictionMapGlob}) +file(GLOB PrepareGlob contractor/*.cpp data_structures/hilbert_value.cpp util/compute_angle.cpp {RestrictionMapGlob}) set(PrepareSources prepare.cpp ${PrepareGlob}) add_executable(osrm-prepare ${PrepareSources} $ $ $ $ $ $ $ $) file(GLOB ServerGlob server/*.cpp) file(GLOB DescriptorGlob descriptors/*.cpp) -file(GLOB DatastructureGlob data_structures/search_engine_data.cpp data_structures/route_parameters.cpp Util/bearing.cpp) +file(GLOB DatastructureGlob data_structures/search_engine_data.cpp data_structures/route_parameters.cpp util/bearing.cpp) list(REMOVE_ITEM DatastructureGlob data_structures/Coordinate.cpp) file(GLOB CoordinateGlob data_structures/coordinate*.cpp) file(GLOB AlgorithmGlob algorithms/*.cpp) @@ -91,8 +91,8 @@ set( ) add_library(COORDINATE OBJECT ${CoordinateGlob}) -add_library(FINGERPRINT OBJECT Util/fingerprint.cpp) -add_library(GITDESCRIPTION OBJECT Util/git_sha.cpp) +add_library(FINGERPRINT OBJECT util/fingerprint.cpp) +add_library(GITDESCRIPTION OBJECT util/git_sha.cpp) add_library(OSRM ${OSRMSources} $ $ $ $ $ $ $) add_dependencies(FINGERPRINT FingerPrintConfigure) diff --git a/Library/OSRM_impl.cpp b/Library/OSRM_impl.cpp index aaf1e3da3..aea85a44c 100644 --- a/Library/OSRM_impl.cpp +++ b/Library/OSRM_impl.cpp @@ -46,9 +46,9 @@ class named_mutex; #include "../server/data_structures/internal_datafacade.hpp" #include "../server/data_structures/shared_barriers.hpp" #include "../server/data_structures/shared_datafacade.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/routed_options.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/make_unique.hpp" +#include "../util/routed_options.hpp" +#include "../util/simple_logger.hpp" #include #include diff --git a/Server/Http/Reply.cpp b/Server/Http/Reply.cpp index 89b931b05..2642e2be2 100644 --- a/Server/Http/Reply.cpp +++ b/Server/Http/Reply.cpp @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "reply.hpp" -#include "../../Util/cast.hpp" +#include "../../util/cast.hpp" namespace http { diff --git a/Server/data_structures/datafacade_base.hpp b/Server/data_structures/datafacade_base.hpp index 2de79f915..0dbeef4b6 100644 --- a/Server/data_structures/datafacade_base.hpp +++ b/Server/data_structures/datafacade_base.hpp @@ -34,9 +34,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/external_memory_node.hpp" #include "../../data_structures/phantom_node.hpp" #include "../../data_structures/turn_instructions.hpp" -#include "../../Util/integer_range.hpp" -#include "../../Util/osrm_exception.hpp" -#include "../../Util/string_util.hpp" +#include "../../util/integer_range.hpp" +#include "../../util/osrm_exception.hpp" +#include "../../util/string_util.hpp" #include "../../typedefs.h" #include diff --git a/Server/data_structures/internal_datafacade.hpp b/Server/data_structures/internal_datafacade.hpp index f25185a1e..8a481c5c5 100644 --- a/Server/data_structures/internal_datafacade.hpp +++ b/Server/data_structures/internal_datafacade.hpp @@ -39,9 +39,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/static_graph.hpp" #include "../../data_structures/static_rtree.hpp" #include "../../data_structures/range_table.hpp" -#include "../../Util/boost_filesystem_2_fix.hpp" -#include "../../Util/graph_loader.hpp" -#include "../../Util/simple_logger.hpp" +#include "../../util/boost_filesystem_2_fix.hpp" +#include "../../util/graph_loader.hpp" +#include "../../util/simple_logger.hpp" #include #include diff --git a/Server/data_structures/shared_datafacade.hpp b/Server/data_structures/shared_datafacade.hpp index 1b038dc89..b6a144174 100644 --- a/Server/data_structures/shared_datafacade.hpp +++ b/Server/data_structures/shared_datafacade.hpp @@ -36,9 +36,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/range_table.hpp" #include "../../data_structures/static_graph.hpp" #include "../../data_structures/static_rtree.hpp" -#include "../../Util/boost_filesystem_2_fix.hpp" -#include "../../Util/make_unique.hpp" -#include "../../Util/simple_logger.hpp" +#include "../../util/boost_filesystem_2_fix.hpp" +#include "../../util/make_unique.hpp" +#include "../../util/simple_logger.hpp" #include #include diff --git a/Server/data_structures/shared_datatype.hpp b/Server/data_structures/shared_datatype.hpp index 9464ff015..0c0b23910 100644 --- a/Server/data_structures/shared_datatype.hpp +++ b/Server/data_structures/shared_datatype.hpp @@ -28,8 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SHARED_DATA_TYPE_HPP #define SHARED_DATA_TYPE_HPP -#include "../../Util/osrm_exception.hpp" -#include "../../Util/simple_logger.hpp" +#include "../../util/osrm_exception.hpp" +#include "../../util/simple_logger.hpp" #include diff --git a/Server/http/reply.cpp b/Server/http/reply.cpp index 89b931b05..2642e2be2 100644 --- a/Server/http/reply.cpp +++ b/Server/http/reply.cpp @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "reply.hpp" -#include "../../Util/cast.hpp" +#include "../../util/cast.hpp" namespace http { diff --git a/Util/cast.hpp b/Util/cast.hpp index 9d09761b1..e28b9ff84 100644 --- a/Util/cast.hpp +++ b/Util/cast.hpp @@ -38,7 +38,8 @@ struct cast { // convert scoped enums to integers template - static auto enum_to_underlying(Enumeration const value) -> typename std::underlying_type::type + static auto enum_to_underlying(Enumeration const value) -> + typename std::underlying_type::type { return static_cast::type>(value); } @@ -145,10 +146,7 @@ struct cast template struct scientific_policy : boost::spirit::karma::real_policies { // we want the numbers always to be in fixed format - static int floatfield(T) - { - return boost::spirit::karma::real_policies::fmtflags::fixed; - } + static int floatfield(T) { return boost::spirit::karma::real_policies::fmtflags::fixed; } static unsigned int precision(T) { return 6; } }; typedef boost::spirit::karma::real_generator> science_type; @@ -174,8 +172,7 @@ struct cast return output; } - static void double_with_two_digits_to_string(const double value, - std::string &output) + static void double_with_two_digits_to_string(const double value, std::string &output) { // The largest 32-bit integer is 4294967295, that is 10 chars // On the safe side, add 1 for sign, and 1 for trailing zero diff --git a/Util/compute_angle.cpp b/Util/compute_angle.cpp index dd1989b80..e83b67b75 100644 --- a/Util/compute_angle.cpp +++ b/Util/compute_angle.cpp @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "compute_angle.hpp" #include "trigonometry_table.hpp" -#include "../Util/mercator.hpp" +#include "../util/mercator.hpp" #include diff --git a/Util/container.hpp b/Util/container.hpp index 343ebe9ba..a35d56a6d 100644 --- a/Util/container.hpp +++ b/Util/container.hpp @@ -37,7 +37,8 @@ namespace osrm template void sort_unique_resize(std::vector &vector) { std::sort(vector.begin(), vector.end()); - const auto number_of_unique_elements = std::unique(vector.begin(), vector.end()) - vector.begin(); + const auto number_of_unique_elements = + std::unique(vector.begin(), vector.end()) - vector.begin(); vector.resize(number_of_unique_elements); } @@ -47,9 +48,11 @@ template void sort_unique_resize(std::vector &vector) // vector.shrink_to_fit(); // } -// template inline void remove_consecutive_duplicates_from_vector(std::vector &vector) +// template inline void remove_consecutive_duplicates_from_vector(std::vector +// &vector) // { -// const auto number_of_unique_elements = std::unique(vector.begin(), vector.end()) - vector.begin(); +// const auto number_of_unique_elements = std::unique(vector.begin(), vector.end()) - +// vector.begin(); // vector.resize(number_of_unique_elements); // } @@ -67,7 +70,8 @@ Function for_each_pair(ForwardIterator begin, ForwardIterator end, Function func while (next != end) { function(*begin, *next); - begin = std::next(begin); next = std::next(next); + begin = std::next(begin); + next = std::next(next); } return function; } @@ -77,6 +81,5 @@ Function for_each_pair(ContainerT &container, Function function) { return for_each_pair(std::begin(container), std::end(container), function); } - } #endif /* CONTAINER_HPP_ */ diff --git a/Util/fingerprint.hpp b/Util/fingerprint.hpp index 43a811deb..494a877ab 100644 --- a/Util/fingerprint.hpp +++ b/Util/fingerprint.hpp @@ -35,7 +35,7 @@ class FingerPrint { public: FingerPrint(); - FingerPrint(const FingerPrint&) = delete; + FingerPrint(const FingerPrint &) = delete; ~FingerPrint(); const boost::uuids::uuid &GetFingerPrint() const; bool IsMagicNumberOK() const; diff --git a/Util/git_sha.hpp b/Util/git_sha.hpp index d1f18a661..9e55deff3 100644 --- a/Util/git_sha.hpp +++ b/Util/git_sha.hpp @@ -30,4 +30,4 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern char g_GIT_DESCRIPTION[]; -#endif //GIT_SHA_HPP +#endif // GIT_SHA_HPP diff --git a/Util/graph_loader.hpp b/Util/graph_loader.hpp index 6c40ee7c7..44f628034 100644 --- a/Util/graph_loader.hpp +++ b/Util/graph_loader.hpp @@ -28,13 +28,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef GRAPH_LOADER_HPP #define GRAPH_LOADER_HPP +#include "fingerprint.hpp" #include "osrm_exception.hpp" +#include "simple_logger.hpp" #include "../data_structures/external_memory_node.hpp" #include "../data_structures/import_edge.hpp" #include "../data_structures/query_node.hpp" #include "../data_structures/restriction.hpp" -#include "../Util/fingerprint.hpp" -#include "../Util/simple_logger.hpp" #include "../typedefs.h" #include @@ -80,7 +80,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, for (NodeID i = 0; i < n; ++i) { input_stream.read((char *)¤t_node, sizeof(ExternalMemoryNode)); - int_to_ext_node_id_map->emplace_back(current_node.lat, current_node.lon, current_node.node_id); + int_to_ext_node_id_map->emplace_back(current_node.lat, current_node.lon, + current_node.node_id); ext_to_int_id_map.emplace(current_node.node_id, i); if (current_node.barrier) { @@ -102,7 +103,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, auto internal_id_iter = ext_to_int_id_map.find(current_restriction.from.node); if (internal_id_iter == ext_to_int_id_map.end()) { - SimpleLogger().Write(logDEBUG) << "Unmapped from node " << current_restriction.from.node << " of restriction"; + SimpleLogger().Write(logDEBUG) << "Unmapped from node " << current_restriction.from.node + << " of restriction"; continue; } current_restriction.from.node = internal_id_iter->second; @@ -110,7 +112,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, internal_id_iter = ext_to_int_id_map.find(current_restriction.via.node); if (internal_id_iter == ext_to_int_id_map.end()) { - SimpleLogger().Write(logDEBUG) << "Unmapped via node " << current_restriction.via.node << " of restriction"; + SimpleLogger().Write(logDEBUG) << "Unmapped via node " << current_restriction.via.node + << " of restriction"; continue; } @@ -119,7 +122,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, internal_id_iter = ext_to_int_id_map.find(current_restriction.to.node); if (internal_id_iter == ext_to_int_id_map.end()) { - SimpleLogger().Write(logDEBUG) << "Unmapped to node " << current_restriction.to.node << " of restriction"; + SimpleLogger().Write(logDEBUG) << "Unmapped to node " << current_restriction.to.node + << " of restriction"; continue; } current_restriction.to.node = internal_id_iter->second; @@ -195,17 +199,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, std::swap(forward, backward); } - edge_list.emplace_back(source, - target, - nameID, - weight, - forward, - backward, - is_roundabout, - ignore_in_grid, - is_access_restricted, - travel_mode, - is_split); + edge_list.emplace_back(source, target, nameID, weight, forward, backward, is_roundabout, + ignore_in_grid, is_access_restricted, travel_mode, is_split); } ext_to_int_id_map.clear(); @@ -216,9 +211,8 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, if ((edge_list[i - 1].target == edge_list[i].target) && (edge_list[i - 1].source == edge_list[i].source)) { - const bool edge_flags_equivalent = - (edge_list[i - 1].forward == edge_list[i].forward) && - (edge_list[i - 1].backward == edge_list[i].backward); + const bool edge_flags_equivalent = (edge_list[i - 1].forward == edge_list[i].forward) && + (edge_list[i - 1].backward == edge_list[i].backward); const bool edge_flags_are_superset1 = (edge_list[i - 1].forward && edge_list[i - 1].backward) && (edge_list[i].forward != edge_list[i].backward); @@ -263,11 +257,11 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, } } } - const auto new_end_iter = std::remove_if(edge_list.begin(), edge_list.end(), [] (const EdgeT &edge) - { - return edge.source == SPECIAL_NODEID || - edge.target == SPECIAL_NODEID; - }); + const auto new_end_iter = + std::remove_if(edge_list.begin(), edge_list.end(), [](const EdgeT &edge) + { + return edge.source == SPECIAL_NODEID || edge.target == SPECIAL_NODEID; + }); edge_list.erase(new_end_iter, edge_list.end()); // remove excess candidates. edge_list.shrink_to_fit(); SimpleLogger().Write() << "Graph loaded ok and has " << edge_list.size() << " edges"; diff --git a/Util/json_renderer.hpp b/Util/json_renderer.hpp index a5fc239bb..adb7c544e 100644 --- a/Util/json_renderer.hpp +++ b/Util/json_renderer.hpp @@ -35,7 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -namespace JSON { +namespace JSON +{ struct Renderer : mapbox::util::static_visitor<> { diff --git a/Util/make_unique.hpp b/Util/make_unique.hpp index 07786feaa..b88145d17 100644 --- a/Util/make_unique.hpp +++ b/Util/make_unique.hpp @@ -54,4 +54,4 @@ template typename std::enable_if::value != 0, void>::type make_unique(Types &&...) = delete; } -#endif //MAKE_UNIQUE_H_ +#endif // MAKE_UNIQUE_H_ diff --git a/Util/osrm_exception.cpp b/Util/osrm_exception.cpp index ebdac6db1..e6b7986e3 100644 --- a/Util/osrm_exception.cpp +++ b/Util/osrm_exception.cpp @@ -29,15 +29,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace osrm { - // This function exists to 'anchor' the class, and stop the compiler from - // copying vtable and RTTI info into every object file that includes - // this header. (Caught by -Wweak-vtables under Clang.) +// This function exists to 'anchor' the class, and stop the compiler from +// copying vtable and RTTI info into every object file that includes +// this header. (Caught by -Wweak-vtables under Clang.) - // More information from the LLVM Coding Standards: - // If a class is defined in a header file and has a vtable (either it has - // virtual methods or it derives from classes with virtual methods), it must - // always have at least one out-of-line virtual method in the class. Without - // this, the compiler will copy the vtable and RTTI into every .o file that - // #includes the header, bloating .o file sizes and increasing link times. - void exception::anchor() const { } +// More information from the LLVM Coding Standards: +// If a class is defined in a header file and has a vtable (either it has +// virtual methods or it derives from classes with virtual methods), it must +// always have at least one out-of-line virtual method in the class. Without +// this, the compiler will copy the vtable and RTTI into every .o file that +// #includes the header, bloating .o file sizes and increasing link times. +void exception::anchor() const {} } diff --git a/Util/range_algorithms.hpp b/Util/range_algorithms.hpp index 208236e6c..5aafd8e17 100644 --- a/Util/range_algorithms.hpp +++ b/Util/range_algorithms.hpp @@ -23,20 +23,20 @@ or see http://www.gnu.org/licenses/agpl.txt. #include -namespace osrm { +namespace osrm +{ -template -auto max_element(const Container & c) -> decltype(std::max_element(c.begin(), c.end())) +template +auto max_element(const Container &c) -> decltype(std::max_element(c.begin(), c.end())) { return std::max_element(c.begin(), c.end()); } -template -auto max_element(const Container & c) -> decltype(std::max_element(c.cbegin(), c.cend())) +template +auto max_element(const Container &c) -> decltype(std::max_element(c.cbegin(), c.cend())) { return std::max_element(c.cbegin(), c.cend()); } - } #endif // RANGE_ALGORITHMS_HPP diff --git a/Util/simple_logger.cpp b/Util/simple_logger.cpp index dbbf34808..5d8821233 100644 --- a/Util/simple_logger.cpp +++ b/Util/simple_logger.cpp @@ -47,10 +47,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace { -static const char COL_RESET[] { "\x1b[0m"}; -static const char RED[] { "\x1b[31m"}; +static const char COL_RESET[]{"\x1b[0m"}; +static const char RED[]{"\x1b[31m"}; #ifndef NDEBUG -static const char YELLOW[] { "\x1b[33m"}; +static const char YELLOW[]{"\x1b[33m"}; #endif // static const char GREEN[] { "\x1b[32m"}; // static const char BLUE[] { "\x1b[34m"}; @@ -95,7 +95,7 @@ std::ostringstream &SimpleLogger::Write(LogLevel lvl) os << "debug"; #endif break; - default: //logINFO: + default: // logINFO: os << "info"; break; } @@ -127,7 +127,7 @@ SimpleLogger::~SimpleLogger() << std::endl; #endif break; - default: //logINFO: + default: // logINFO: std::cout << os.str() << (is_terminal ? COL_RESET : "") << std::endl; break; } diff --git a/Util/std_hash.hpp b/Util/std_hash.hpp index 59c4ad9b4..8b4af3dd8 100644 --- a/Util/std_hash.hpp +++ b/Util/std_hash.hpp @@ -33,29 +33,24 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // this is largely inspired by boost's hash combine as can be found in // "The C++ Standard Library" 2nd Edition. Nicolai M. Josuttis. 2012. -namespace { +namespace +{ -template -void hash_combine(std::size_t &seed, const T& val) +template void hash_combine(std::size_t &seed, const T &val) { seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } -template -void hash_val(std::size_t &seed, const T& val) +template void hash_val(std::size_t &seed, const T &val) { hash_combine(seed, val); } + +template +void hash_val(std::size_t &seed, const T &val, const Types &... args) { hash_combine(seed, val); + hash_val(seed, args...); } -template -void hash_val(std::size_t &seed, const T& val, const Types& ... args) -{ - hash_combine(seed, val); - hash_val(seed, args ...); -} - -template -std::size_t hash_val(const Types&... args) +template std::size_t hash_val(const Types &... args) { std::size_t seed = 0; hash_val(seed, args...); diff --git a/Util/timing_util.hpp b/Util/timing_util.hpp index 1bbea472a..2279bd083 100644 --- a/Util/timing_util.hpp +++ b/Util/timing_util.hpp @@ -42,39 +42,49 @@ struct GlobalTimer class GlobalTimerFactory { -public: - static GlobalTimerFactory& get() + public: + static GlobalTimerFactory &get() { static GlobalTimerFactory instance; return instance; } - GlobalTimer& getGlobalTimer(const std::string& name) + GlobalTimer &getGlobalTimer(const std::string &name) { std::lock_guard lock(map_mutex); return timer_map[name]; } -private: + private: std::mutex map_mutex; std::unordered_map timer_map; }; -#define GLOBAL_TIMER_AQUIRE(_X) auto& _X##_global_timer = GlobalTimerFactory::get().getGlobalTimer(#_X) +#define GLOBAL_TIMER_AQUIRE(_X) \ + auto &_X##_global_timer = GlobalTimerFactory::get().getGlobalTimer(#_X) #define GLOBAL_TIMER_RESET(_X) _X##_global_timer.time = 0 #define GLOBAL_TIMER_START(_X) TIMER_START(_X) -#define GLOBAL_TIMER_STOP(_X) TIMER_STOP(_X); _X##_global_timer.time += TIMER_NSEC(_X) +#define GLOBAL_TIMER_STOP(_X) \ + TIMER_STOP(_X); \ + _X##_global_timer.time += TIMER_NSEC(_X) #define GLOBAL_TIMER_NSEC(_X) static_cast(_X##_global_timer.time) #define GLOBAL_TIMER_USEC(_X) (_X##_global_timer.time / 1000.0) #define GLOBAL_TIMER_MSEC(_X) (_X##_global_timer.time / 1000.0 / 1000.0) -#define GLOBAL_TIMER_SEC(_X) (_X##_global_timer.time / 1000.0 / 1000.0 / 1000.0) +#define GLOBAL_TIMER_SEC(_X) (_X##_global_timer.time / 1000.0 / 1000.0 / 1000.0) #define TIMER_START(_X) auto _X##_start = std::chrono::steady_clock::now(), _X##_stop = _X##_start #define TIMER_STOP(_X) _X##_stop = std::chrono::steady_clock::now() -#define TIMER_NSEC(_X) std::chrono::duration_cast(_X##_stop - _X##_start).count() -#define TIMER_USEC(_X) std::chrono::duration_cast(_X##_stop - _X##_start).count() -#define TIMER_MSEC(_X) (0.000001*std::chrono::duration_cast(_X##_stop - _X##_start).count()) -#define TIMER_SEC(_X) (0.000001*std::chrono::duration_cast(_X##_stop - _X##_start).count()) -#define TIMER_MIN(_X) std::chrono::duration_cast(_X##_stop - _X##_start).count() +#define TIMER_NSEC(_X) \ + std::chrono::duration_cast(_X##_stop - _X##_start).count() +#define TIMER_USEC(_X) \ + std::chrono::duration_cast(_X##_stop - _X##_start).count() +#define TIMER_MSEC(_X) \ + (0.000001 * \ + std::chrono::duration_cast(_X##_stop - _X##_start).count()) +#define TIMER_SEC(_X) \ + (0.000001 * \ + std::chrono::duration_cast(_X##_stop - _X##_start).count()) +#define TIMER_MIN(_X) \ + std::chrono::duration_cast(_X##_stop - _X##_start).count() #endif // TIMING_UTIL_HPP diff --git a/Util/xml_renderer.hpp b/Util/xml_renderer.hpp index 4f08cddbe..bbf2287e1 100644 --- a/Util/xml_renderer.hpp +++ b/Util/xml_renderer.hpp @@ -32,7 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -namespace JSON { +namespace JSON +{ struct XMLToArrayRenderer : mapbox::util::static_visitor<> { @@ -66,7 +67,6 @@ struct XMLToArrayRenderer : mapbox::util::static_visitor<> out.push_back(' '); out.insert(out.end(), ++(*iterator).first.begin(), (*iterator).first.end()); out.push_back('='); - } mapbox::util::apply_visitor(XMLToArrayRenderer(out), (*iterator).second); if (iterator->first.at(0) != '_') @@ -111,29 +111,28 @@ struct XMLToArrayRenderer : mapbox::util::static_visitor<> std::vector &out; }; -template -inline void xml_render(std::vector &out, const JSONObject &object) +template inline void xml_render(std::vector &out, const JSONObject &object) { Value value = object; mapbox::util::apply_visitor(XMLToArrayRenderer(out), value); } -template -inline void gpx_render(std::vector &out, const JSONObject &object) +template inline void gpx_render(std::vector &out, const JSONObject &object) { // add header - const std::string header {"Data (c) OpenStreetMap contributors (ODbL)"}; + const std::string header{ + "Data (c) OpenStreetMap contributors (ODbL)"}; out.insert(out.end(), header.begin(), header.end()); xml_render(out, object); - const std::string footer {""}; + const std::string footer{""}; out.insert(out.end(), footer.begin(), footer.end()); } } // namespace JSON diff --git a/algorithms/douglas_peucker.cpp b/algorithms/douglas_peucker.cpp index fabea1810..3de89da4e 100644 --- a/algorithms/douglas_peucker.cpp +++ b/algorithms/douglas_peucker.cpp @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "douglas_peucker.hpp" #include "../data_structures/segment_information.hpp" -#include "../Util/integer_range.hpp" +#include "../util/integer_range.hpp" #include #include diff --git a/algorithms/object_encoder.hpp b/algorithms/object_encoder.hpp index af6e0d9ca..5a1e75309 100644 --- a/algorithms/object_encoder.hpp +++ b/algorithms/object_encoder.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2013, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef OBJECT_ENCODER_HPP #define OBJECT_ENCODER_HPP -#include "../Util/string_util.hpp" +#include "../util/string_util.hpp" #include #include @@ -49,8 +49,7 @@ struct ObjectEncoder 8, 6>; - template - static void EncodeToBase64(const ObjectT &object, std::string &encoded) + template static void EncodeToBase64(const ObjectT &object, std::string &encoded) { const char *char_ptr_to_object = (const char *)&object; std::vector data(sizeof(object)); @@ -71,8 +70,7 @@ struct ObjectEncoder replaceAll(encoded, "/", "_"); } - template - static void DecodeFromBase64(const std::string &input, ObjectT &object) + template static void DecodeFromBase64(const std::string &input, ObjectT &object) { try { @@ -81,8 +79,7 @@ struct ObjectEncoder replaceAll(encoded, "-", "+"); replaceAll(encoded, "_", "/"); - std::copy(binary_t(encoded.begin()), - binary_t(encoded.begin() + encoded.length() - 1), + std::copy(binary_t(encoded.begin()), binary_t(encoded.begin() + encoded.length() - 1), (char *)&object); } catch (...) diff --git a/algorithms/tiny_components.hpp b/algorithms/tiny_components.hpp index 04f380a1b..5354fc785 100644 --- a/algorithms/tiny_components.hpp +++ b/algorithms/tiny_components.hpp @@ -37,10 +37,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/restriction_map.hpp" #include "../data_structures/turn_instructions.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/std_hash.hpp" -#include "../Util/timing_util.hpp" +#include "../util/integer_range.hpp" +#include "../util/simple_logger.hpp" +#include "../util/std_hash.hpp" +#include "../util/timing_util.hpp" #include @@ -48,7 +48,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include - #include #include @@ -57,8 +56,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -template -class TarjanSCC +template class TarjanSCC { struct TarjanStackFrame { @@ -83,13 +81,12 @@ class TarjanSCC std::size_t size_one_counter; public: - template + template TarjanSCC(std::shared_ptr graph, const RestrictionMap &restrictions, const ContainerT &barrier_node_list) - : components_index(graph->GetNumberOfNodes(), SPECIAL_NODEID), - m_node_based_graph(graph), m_restriction_map(restrictions), - size_one_counter(0) + : components_index(graph->GetNumberOfNodes(), SPECIAL_NODEID), m_node_based_graph(graph), + m_restriction_map(restrictions), size_one_counter(0) { barrier_node_set.insert(std::begin(barrier_node_list), std::end(barrier_node_list)); BOOST_ASSERT(m_node_based_graph->GetNumberOfNodes() > 0); @@ -107,8 +104,9 @@ class TarjanSCC unsigned component_index = 0, size_of_current_component = 0; int index = 0; const NodeID last_node = m_node_based_graph->GetNumberOfNodes(); - std::vector processing_node_before_recursion(m_node_based_graph->GetNumberOfNodes(), true); - for(const NodeID node : osrm::irange(0u, last_node)) + std::vector processing_node_before_recursion(m_node_based_graph->GetNumberOfNodes(), + true); + for (const NodeID node : osrm::irange(0u, last_node)) { if (SPECIAL_NODEID == components_index[node]) { @@ -150,13 +148,11 @@ class TarjanSCC const auto vprime = m_node_based_graph->GetTarget(current_edge); // Traverse outgoing edges - if (barrier_node_set.find(v) != barrier_node_set.end() && - u != vprime) + if (barrier_node_set.find(v) != barrier_node_set.end() && u != vprime) { // continue; } - if (to_node_of_only_restriction != std::numeric_limits::max() && vprime == to_node_of_only_restriction) { @@ -219,35 +215,25 @@ class TarjanSCC } TIMER_STOP(SCC_RUN); - SimpleLogger().Write() << "SCC run took: " << TIMER_MSEC(SCC_RUN)/1000. << "s"; + SimpleLogger().Write() << "SCC run took: " << TIMER_MSEC(SCC_RUN) / 1000. << "s"; - size_one_counter = std::count_if(component_size_vector.begin(), - component_size_vector.end(), + size_one_counter = std::count_if(component_size_vector.begin(), component_size_vector.end(), [](unsigned value) { - return 1 == value; - }); + return 1 == value; + }); } - std::size_t get_number_of_components() const - { - return component_size_vector.size(); - } + std::size_t get_number_of_components() const { return component_size_vector.size(); } - unsigned get_size_one_count() const - { - return size_one_counter; - } + unsigned get_size_one_count() const { return size_one_counter; } unsigned get_component_size(const NodeID node) const { return component_size_vector[components_index[node]]; } - unsigned get_component_id(const NodeID node) const - { - return components_index[node]; - } + unsigned get_component_id(const NodeID node) const { return components_index[node]; } }; #endif /* TINY_COMPONENTS_HPP */ diff --git a/benchmarks/static_rtree.cpp b/benchmarks/static_rtree.cpp index e7095e9f6..7d2ae9f55 100644 --- a/benchmarks/static_rtree.cpp +++ b/benchmarks/static_rtree.cpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/query_node.hpp" #include "../data_structures/shared_memory_vector_wrapper.hpp" #include "../data_structures/static_rtree.hpp" -#include "../Util/boost_filesystem_2_fix.hpp" +#include "../util/boost_filesystem_2_fix.hpp" #include "../data_structures/edge_based_node.hpp" #include diff --git a/cmake/FingerPrint-Config.cmake b/cmake/FingerPrint-Config.cmake index 9ea843519..fe710ac63 100644 --- a/cmake/FingerPrint-Config.cmake +++ b/cmake/FingerPrint-Config.cmake @@ -1,10 +1,10 @@ -set(OLDFILE ${SOURCE_DIR}/Util/fingerprint.cpp) +set(OLDFILE ${SOURCE_DIR}/util/fingerprint.cpp) if (EXISTS ${OLDFILE}) file(REMOVE_RECURSE ${OLDFILE}) endif() file(MD5 ${SOURCE_DIR}/prepare.cpp MD5PREPARE) file(MD5 ${SOURCE_DIR}/data_structures/static_rtree.hpp MD5RTREE) -file(MD5 ${SOURCE_DIR}/Util/graph_loader.hpp MD5GRAPH) +file(MD5 ${SOURCE_DIR}/util/graph_loader.hpp MD5GRAPH) file(MD5 ${SOURCE_DIR}/server/data_structures/internal_datafacade.hpp MD5OBJECTS) -CONFIGURE_FILE( ${SOURCE_DIR}/Util/fingerprint.cpp.in ${SOURCE_DIR}/Util/fingerprint.cpp ) +CONFIGURE_FILE( ${SOURCE_DIR}/util/fingerprint.cpp.in ${SOURCE_DIR}/util/fingerprint.cpp ) diff --git a/contractor/contractor.hpp b/contractor/contractor.hpp index c8c107cdb..ccfabbc8f 100644 --- a/contractor/contractor.hpp +++ b/contractor/contractor.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -35,9 +35,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/query_edge.hpp" #include "../data_structures/xor_fast_hash.hpp" #include "../data_structures/xor_fast_hash_storage.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/timing_util.hpp" +#include "../util/integer_range.hpp" +#include "../util/simple_logger.hpp" +#include "../util/timing_util.hpp" #include "../typedefs.h" #include @@ -92,9 +92,11 @@ class Contractor }; using ContractorGraph = DynamicGraph; - // using ContractorHeap = BinaryHeap + // using ContractorHeap = BinaryHeap // >; - using ContractorHeap = BinaryHeap>; + using ContractorHeap = + BinaryHeap>; using ContractorEdge = ContractorGraph::InputEdge; struct ContractorThreadData @@ -131,15 +133,14 @@ class Contractor bool is_independent : 1; }; - struct ThreadDataContainer { - explicit ThreadDataContainer(int number_of_nodes) : number_of_nodes(number_of_nodes) {} + explicit ThreadDataContainer(int number_of_nodes) : number_of_nodes(number_of_nodes) {} - inline ContractorThreadData* getThreadData() + inline ContractorThreadData *getThreadData() { bool exists = false; - auto& ref = data.local(exists); + auto &ref = data.local(exists); if (!exists) { ref = std::make_shared(number_of_nodes); @@ -149,7 +150,8 @@ class Contractor } int number_of_nodes; - using EnumerableThreadData = tbb::enumerable_thread_specific>; + using EnumerableThreadData = + tbb::enumerable_thread_specific>; EnumerableThreadData data; }; @@ -162,29 +164,25 @@ class Contractor const auto dend = input_edge_list.dend(); for (auto diter = input_edge_list.dbegin(); diter != dend; ++diter) { - BOOST_ASSERT_MSG(static_cast(std::max(diter->weight, 1)) > 0, "edge distance < 1"); + BOOST_ASSERT_MSG(static_cast(std::max(diter->weight, 1)) > 0, + "edge distance < 1"); #ifndef NDEBUG if (static_cast(std::max(diter->weight, 1)) > 24 * 60 * 60 * 10) { - SimpleLogger().Write(logWARNING) << "Edge weight large -> " - << static_cast(std::max(diter->weight, 1)); + SimpleLogger().Write(logWARNING) + << "Edge weight large -> " + << static_cast(std::max(diter->weight, 1)); } #endif edges.emplace_back(diter->source, diter->target, - static_cast(std::max(diter->weight, 1)), - 1, - diter->edge_id, - false, - diter->forward ? true : false, - diter->backward ? true : false); + static_cast(std::max(diter->weight, 1)), 1, + diter->edge_id, false, diter->forward ? true : false, + diter->backward ? true : false); edges.emplace_back(diter->target, diter->source, - static_cast(std::max(diter->weight, 1)), - 1, - diter->edge_id, - false, - diter->backward ? true : false, - diter->forward ? true : false); + static_cast(std::max(diter->weight, 1)), 1, + diter->edge_id, false, diter->backward ? true : false, + diter->forward ? true : false); } // clear input vector input_edge_list.clear(); @@ -282,20 +280,20 @@ class Contractor std::cout << "contractor finished initalization" << std::endl; } - ~Contractor() { } + ~Contractor() {} void Run() { // for the preperation we can use a big grain size, which is much faster (probably cache) - constexpr size_t InitGrainSize = 100000; - constexpr size_t PQGrainSize = 100000; + constexpr size_t InitGrainSize = 100000; + constexpr size_t PQGrainSize = 100000; // auto_partitioner will automatically increase the blocksize if we have // a lot of data. It is *important* for the last loop iterations // (which have a very small dataset) that it is devisible. constexpr size_t IndependentGrainSize = 1; - constexpr size_t ContractGrainSize = 1; - constexpr size_t NeighboursGrainSize = 1; - constexpr size_t DeleteGrainSize = 1; + constexpr size_t ContractGrainSize = 1; + constexpr size_t NeighboursGrainSize = 1; + constexpr size_t DeleteGrainSize = 1; const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes(); Percent p(number_of_nodes); @@ -307,30 +305,28 @@ class Contractor std::vector node_priorities(number_of_nodes); std::vector node_data(number_of_nodes); - // initialize priorities in parallel tbb::parallel_for(tbb::blocked_range(0, number_of_nodes, InitGrainSize), - [&remaining_nodes](const tbb::blocked_range& range) - { - for (int x = range.begin(); x != range.end(); ++x) - { - remaining_nodes[x].id = x; - } - } - ); - + [&remaining_nodes](const tbb::blocked_range &range) + { + for (int x = range.begin(); x != range.end(); ++x) + { + remaining_nodes[x].id = x; + } + }); std::cout << "initializing elimination PQ ..." << std::flush; tbb::parallel_for(tbb::blocked_range(0, number_of_nodes, PQGrainSize), - [this, &node_priorities, &node_data, &thread_data_list](const tbb::blocked_range& range) - { - ContractorThreadData *data = thread_data_list.getThreadData(); - for (int x = range.begin(); x != range.end(); ++x) - { - node_priorities[x] = this->EvaluateNodePriority(data, &node_data[x], x); - } - } - ); + [this, &node_priorities, &node_data, &thread_data_list]( + const tbb::blocked_range &range) + { + ContractorThreadData *data = thread_data_list.getThreadData(); + for (int x = range.begin(); x != range.end(); ++x) + { + node_priorities[x] = + this->EvaluateNodePriority(data, &node_data[x], x); + } + }); std::cout << "ok" << std::endl << "preprocessing " << number_of_nodes << " nodes ..." << std::flush; @@ -368,7 +364,8 @@ class Contractor remaining_nodes[new_node_id].id = new_node_id; } // walk over all nodes - for (const auto i : osrm::irange(0, contractor_graph->GetNumberOfNodes())) + for (const auto i : + osrm::irange(0, contractor_graph->GetNumberOfNodes())) { const NodeID source = i; for (auto current_edge : contractor_graph->GetAdjacentEdgeRange(source)) @@ -384,11 +381,9 @@ class Contractor { // node is not yet contracted. // add (renumbered) outgoing edges to new DynamicGraph. - ContractorEdge new_edge = { - new_node_id_from_orig_id_map[source], - new_node_id_from_orig_id_map[target], - data - }; + ContractorEdge new_edge = {new_node_id_from_orig_id_map[source], + new_node_id_from_orig_id_map[target], + data}; new_edge.data.is_original_via_node_ID = true; BOOST_ASSERT_MSG(UINT_MAX != new_node_id_from_orig_id_map[source], @@ -427,28 +422,30 @@ class Contractor const int last = (int)remaining_nodes.size(); tbb::parallel_for(tbb::blocked_range(0, last, IndependentGrainSize), - [this, &node_priorities, &remaining_nodes, &thread_data_list](const tbb::blocked_range& range) - { - ContractorThreadData *data = thread_data_list.getThreadData(); - // determine independent node set - for (int i = range.begin(); i != range.end(); ++i) - { - const NodeID node = remaining_nodes[i].id; - remaining_nodes[i].is_independent = - this->IsNodeIndependent(node_priorities, data, node); - } - } - ); + [this, &node_priorities, &remaining_nodes, &thread_data_list]( + const tbb::blocked_range &range) + { + ContractorThreadData *data = thread_data_list.getThreadData(); + // determine independent node set + for (int i = range.begin(); i != range.end(); ++i) + { + const NodeID node = remaining_nodes[i].id; + remaining_nodes[i].is_independent = + this->IsNodeIndependent(node_priorities, data, node); + } + }); - const auto first = stable_partition(remaining_nodes.begin(), - remaining_nodes.end(), + const auto first = stable_partition(remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data) - { return !node_data.is_independent; }); + { + return !node_data.is_independent; + }); const int first_independent_node = static_cast(first - remaining_nodes.begin()); // contract independent nodes - tbb::parallel_for(tbb::blocked_range(first_independent_node, last, ContractGrainSize), - [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range& range) + tbb::parallel_for( + tbb::blocked_range(first_independent_node, last, ContractGrainSize), + [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.getThreadData(); for (int position = range.begin(); position != range.end(); ++position) @@ -456,19 +453,18 @@ class Contractor const NodeID x = remaining_nodes[position].id; this->ContractNode(data, x); } - } - ); + }); // make sure we really sort each block - tbb::parallel_for(thread_data_list.data.range(), - [&](const ThreadDataContainer::EnumerableThreadData::range_type& range) + tbb::parallel_for( + thread_data_list.data.range(), + [&](const ThreadDataContainer::EnumerableThreadData::range_type &range) { - for (auto& data : range) - std::sort(data->inserted_edges.begin(), - data->inserted_edges.end()); - } - ); - tbb::parallel_for(tbb::blocked_range(first_independent_node, last, DeleteGrainSize), - [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range& range) + for (auto &data : range) + std::sort(data->inserted_edges.begin(), data->inserted_edges.end()); + }); + tbb::parallel_for( + tbb::blocked_range(first_independent_node, last, DeleteGrainSize), + [this, &remaining_nodes, &thread_data_list](const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.getThreadData(); for (int position = range.begin(); position != range.end(); ++position) @@ -476,15 +472,15 @@ class Contractor const NodeID x = remaining_nodes[position].id; this->DeleteIncomingEdges(data, x); } - } - ); + }); // insert new edges - for (auto& data : thread_data_list.data) + for (auto &data : thread_data_list.data) { for (const ContractorEdge &edge : data->inserted_edges) { - const EdgeID current_edge_ID = contractor_graph->FindEdge(edge.source, edge.target); + const EdgeID current_edge_ID = + contractor_graph->FindEdge(edge.source, edge.target); if (current_edge_ID < contractor_graph->EndEdges(edge.source)) { ContractorGraph::EdgeData ¤t_data = @@ -503,8 +499,10 @@ class Contractor data->inserted_edges.clear(); } - tbb::parallel_for(tbb::blocked_range(first_independent_node, last, NeighboursGrainSize), - [this, &remaining_nodes, &node_priorities, &node_data, &thread_data_list](const tbb::blocked_range& range) + tbb::parallel_for( + tbb::blocked_range(first_independent_node, last, NeighboursGrainSize), + [this, &remaining_nodes, &node_priorities, &node_data, &thread_data_list]( + const tbb::blocked_range &range) { ContractorThreadData *data = thread_data_list.getThreadData(); for (int position = range.begin(); position != range.end(); ++position) @@ -512,8 +510,7 @@ class Contractor NodeID x = remaining_nodes[position].id; this->UpdateNodeNeighbours(node_priorities, node_data, data, x); } - } - ); + }); // remove contracted nodes from the pool number_of_contracted_nodes += last - first_independent_node; @@ -774,17 +771,11 @@ class Contractor { inserted_edges.emplace_back(source, target, path_distance, out_data.originalEdges + in_data.originalEdges, - node, - true, - true, - false); + node, true, true, false); inserted_edges.emplace_back(target, source, path_distance, out_data.originalEdges + in_data.originalEdges, - node, - true, - false, - true); + node, true, false, true); } } } @@ -883,10 +874,9 @@ class Contractor return true; } - inline bool IsNodeIndependent( - const std::vector &priorities, - ContractorThreadData *const data, - NodeID node) const + inline bool IsNodeIndependent(const std::vector &priorities, + ContractorThreadData *const data, + NodeID node) const { const float priority = priorities[node]; diff --git a/contractor/edge_based_graph_factory.cpp b/contractor/edge_based_graph_factory.cpp index 692bf2aa2..4f50b77b5 100644 --- a/contractor/edge_based_graph_factory.cpp +++ b/contractor/edge_based_graph_factory.cpp @@ -28,11 +28,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "edge_based_graph_factory.hpp" #include "../algorithms/tiny_components.hpp" #include "../data_structures/percent.hpp" -#include "../Util/compute_angle.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/lua_util.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/timing_util.hpp" +#include "../util/compute_angle.hpp" +#include "../util/integer_range.hpp" +#include "../util/lua_util.hpp" +#include "../util/simple_logger.hpp" +#include "../util/timing_util.hpp" #include diff --git a/contractor/geometry_compressor.cpp b/contractor/geometry_compressor.cpp index 9458c4415..5af89c297 100644 --- a/contractor/geometry_compressor.cpp +++ b/contractor/geometry_compressor.cpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "geometry_compressor.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/simple_logger.hpp" #include #include @@ -174,8 +174,8 @@ void GeometryCompressor::CompressEdge(const EdgeID edge_id_1, m_compressed_geometries[list_to_remove_index]; // found an existing list, append it to the list of edge_id_1 - edge_bucket_list1.insert( - edge_bucket_list1.end(), edge_bucket_list2.begin(), edge_bucket_list2.end()); + edge_bucket_list1.insert(edge_bucket_list1.end(), edge_bucket_list2.begin(), + edge_bucket_list2.end()); // remove the list of edge_id_2 m_edge_id_to_list_index_map.erase(edge_id_2); @@ -211,9 +211,8 @@ void GeometryCompressor::PrintStatistics() const "\n compressed edges: " << compressed_edges << "\n compressed geometries: " << compressed_geometries << "\n longest chain length: " << longest_chain_length - << "\n cmpr ratio: " - << ((float)compressed_edges / - std::max(compressed_geometries, (uint64_t)1)) + << "\n cmpr ratio: " << ((float)compressed_edges / + std::max(compressed_geometries, (uint64_t)1)) << "\n avg chain length: " << (float)compressed_geometries / std::max((uint64_t)1, compressed_edges); @@ -226,16 +225,15 @@ GeometryCompressor::GetBucketReference(const EdgeID edge_id) const return m_compressed_geometries.at(index); } - NodeID GeometryCompressor::GetFirstNodeIDOfBucket(const EdgeID edge_id) const - { - const auto &bucket = GetBucketReference(edge_id); - BOOST_ASSERT(bucket.size() >= 2); - return bucket[1].first; - } - NodeID GeometryCompressor::GetLastNodeIDOfBucket(const EdgeID edge_id) const - { - const auto &bucket = GetBucketReference(edge_id); - BOOST_ASSERT(bucket.size() >= 2); - return bucket[bucket.size()-2].first; - } - +NodeID GeometryCompressor::GetFirstNodeIDOfBucket(const EdgeID edge_id) const +{ + const auto &bucket = GetBucketReference(edge_id); + BOOST_ASSERT(bucket.size() >= 2); + return bucket[1].first; +} +NodeID GeometryCompressor::GetLastNodeIDOfBucket(const EdgeID edge_id) const +{ + const auto &bucket = GetBucketReference(edge_id); + BOOST_ASSERT(bucket.size() >= 2); + return bucket[bucket.size() - 2].first; +} diff --git a/contractor/processing_chain.cpp b/contractor/processing_chain.cpp index 46c12d0dd..ccff7fd09 100644 --- a/contractor/processing_chain.cpp +++ b/contractor/processing_chain.cpp @@ -34,15 +34,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/static_rtree.hpp" #include "../data_structures/restriction_map.hpp" -#include "../Util/git_sha.hpp" -#include "../Util/graph_loader.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/lua_util.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/string_util.hpp" -#include "../Util/timing_util.hpp" +#include "../util/git_sha.hpp" +#include "../util/graph_loader.hpp" +#include "../util/integer_range.hpp" +#include "../util/lua_util.hpp" +#include "../util/make_unique.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" +#include "../util/string_util.hpp" +#include "../util/timing_util.hpp" #include "../typedefs.h" #include diff --git a/data_structures/coordinate.cpp b/data_structures/coordinate.cpp index 031fafdce..bbe4f18ff 100644 --- a/data_structures/coordinate.cpp +++ b/data_structures/coordinate.cpp @@ -27,9 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "coordinate_calculation.hpp" -#include "../Util/mercator.hpp" +#include "../util/mercator.hpp" #ifndef NDEBUG -#include "../Util/simple_logger.hpp" +#include "../util/simple_logger.hpp" #endif #include #include diff --git a/data_structures/coordinate_calculation.cpp b/data_structures/coordinate_calculation.cpp index 4ca281115..326a87981 100644 --- a/data_structures/coordinate_calculation.cpp +++ b/data_structures/coordinate_calculation.cpp @@ -27,8 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "coordinate_calculation.hpp" -#include "../Util/mercator.hpp" -#include "../Util/string_util.hpp" +#include "../util/mercator.hpp" +#include "../util/string_util.hpp" #include diff --git a/data_structures/deallocating_vector.hpp b/data_structures/deallocating_vector.hpp index e2f82cfb0..5ea2a81ce 100644 --- a/data_structures/deallocating_vector.hpp +++ b/data_structures/deallocating_vector.hpp @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef DEALLOCATING_VECTOR_HPP #define DEALLOCATING_VECTOR_HPP -#include "../Util/integer_range.hpp" +#include "../util/integer_range.hpp" #include @@ -171,7 +171,10 @@ class DeallocatingVector // this forward-only iterator deallocates all buckets that have been visited using deallocation_iterator = DeallocatingVectorRemoveIterator; - DeallocatingVector() : current_size(0) { bucket_list.emplace_back(new ElementT[ELEMENTS_PER_BLOCK]); } + DeallocatingVector() : current_size(0) + { + bucket_list.emplace_back(new ElementT[ELEMENTS_PER_BLOCK]); + } ~DeallocatingVector() { clear(); } @@ -192,7 +195,8 @@ class DeallocatingVector bucket = nullptr; } } - bucket_list.clear(); bucket_list.shrink_to_fit(); + bucket_list.clear(); + bucket_list.shrink_to_fit(); current_size = 0; } @@ -222,7 +226,7 @@ class DeallocatingVector ++current_size; } - void reserve(const std::size_t) const { /* don't do anything */ } + void reserve(const std::size_t) const { /* don't do anything */} void resize(const std::size_t new_size) { @@ -234,9 +238,10 @@ class DeallocatingVector } } else - { // down-size + { // down-size const std::size_t number_of_necessary_buckets = 1 + (new_size / ELEMENTS_PER_BLOCK); - for (const auto bucket_index : osrm::irange(number_of_necessary_buckets, bucket_list.size())) + for (const auto bucket_index : + osrm::irange(number_of_necessary_buckets, bucket_list.size())) { if (nullptr != bucket_list[bucket_index]) { @@ -291,8 +296,7 @@ class DeallocatingVector return (bucket_list[_bucket][_index]); } - template - void append(InputIterator first, const InputIterator last) + template void append(InputIterator first, const InputIterator last) { InputIterator position = first; while (position != last) diff --git a/data_structures/dynamic_graph.hpp b/data_structures/dynamic_graph.hpp index 7244d1e9c..4a666c136 100644 --- a/data_structures/dynamic_graph.hpp +++ b/data_structures/dynamic_graph.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define DYNAMICGRAPH_HPP #include "deallocating_vector.hpp" -#include "../Util/integer_range.hpp" +#include "../util/integer_range.hpp" #include @@ -55,10 +55,17 @@ template class DynamicGraph NodeIterator target; EdgeDataT data; - InputEdge() : source(std::numeric_limits::max()), target(std::numeric_limits::max()) { } + InputEdge() + : source(std::numeric_limits::max()), + target(std::numeric_limits::max()) + { + } - template - InputEdge(NodeIterator source, NodeIterator target, Ts &&...data) : source(source), target(target), data(std::forward(data)...) { } + template + InputEdge(NodeIterator source, NodeIterator target, Ts &&... data) + : source(source), target(target), data(std::forward(data)...) + { + } bool operator<(const InputEdge &right) const { @@ -106,7 +113,7 @@ template class DynamicGraph for (const auto node : osrm::irange(0u, number_of_nodes)) { for (const auto i : osrm::irange(node_list[node].firstEdge, - node_list[node].firstEdge + node_list[node].edges)) + node_list[node].firstEdge + node_list[node].edges)) { edge_list[i].target = graph[edge].target; edge_list[i].data = graph[edge].data; diff --git a/data_structures/node_based_graph.hpp b/data_structures/node_based_graph.hpp index 8fe7b7550..49dba2c08 100644 --- a/data_structures/node_based_graph.hpp +++ b/data_structures/node_based_graph.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "dynamic_graph.hpp" #include "import_edge.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/simple_logger.hpp" #include @@ -40,9 +40,9 @@ struct NodeBasedEdgeData { NodeBasedEdgeData() : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), - nameID(std::numeric_limits::max()), - isAccessRestricted(false), shortcut(false), forward(false), backward(false), - roundabout(false), ignore_in_grid(false), travel_mode(TRAVEL_MODE_INACCESSIBLE) + nameID(std::numeric_limits::max()), isAccessRestricted(false), shortcut(false), + forward(false), backward(false), roundabout(false), ignore_in_grid(false), + travel_mode(TRAVEL_MODE_INACCESSIBLE) { } @@ -85,7 +85,8 @@ using SimpleNodeBasedDynamicGraph = DynamicGraph; inline std::shared_ptr NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector &input_edge_list) { - static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption"); + static_assert(sizeof(NodeBasedEdgeData) == 16, + "changing node based edge data size changes memory consumption"); DeallocatingVector edges_list; NodeBasedDynamicGraph::InputEdge edge; @@ -134,7 +135,7 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector::max(); + forward_edge.data.distance = reverse_edge.data.distance = std::numeric_limits::max(); // remove parallel edges - while (i < edges_list.size() && edges_list[i].source == source && edges_list[i].target == target) + while (i < edges_list.size() && edges_list[i].source == source && + edges_list[i].target == target) { if (edges_list[i].data.forward) { @@ -189,17 +190,20 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector(static_cast(number_of_nodes), edges_list); + auto graph = std::make_shared( + static_cast(number_of_nodes), edges_list); return graph; } -template +template inline std::shared_ptr SimpleNodeBasedDynamicGraphFromEdges(int number_of_nodes, std::vector &input_edge_list) { - static_assert(sizeof(NodeBasedEdgeData) == 16, "changing node based edge data size changes memory consumption"); + static_assert(sizeof(NodeBasedEdgeData) == 16, + "changing node based edge data size changes memory consumption"); tbb::parallel_sort(input_edge_list.begin(), input_edge_list.end()); DeallocatingVector edges_list; @@ -218,10 +222,10 @@ SimpleNodeBasedDynamicGraphFromEdges(int number_of_nodes, std::vector(number_of_nodes, edges_list); return graph; diff --git a/data_structures/range_table.hpp b/data_structures/range_table.hpp index eef268b9d..ec0167231 100644 --- a/data_structures/range_table.hpp +++ b/data_structures/range_table.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef RANGE_TABLE_HPP #define RANGE_TABLE_HPP -#include "../Util/integer_range.hpp" +#include "../util/integer_range.hpp" #include "shared_memory_factory.hpp" #include "shared_memory_vector_wrapper.hpp" @@ -41,13 +41,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * and otherwise the compiler gets confused. */ -template class RangeTable; +template class RangeTable; -template -std::ostream& operator<<(std::ostream &out, const RangeTable &table); +template +std::ostream &operator<<(std::ostream &out, const RangeTable &table); -template -std::istream& operator>>(std::istream &in, RangeTable &table); +template +std::istream &operator>>(std::istream &in, RangeTable &table); /** * Stores adjacent ranges in a compressed format. @@ -58,33 +58,34 @@ std::istream& operator>>(std::istream &in, RangeTable -class RangeTable +template class RangeTable { -public: - + public: using BlockT = std::array; using BlockContainerT = typename ShM::vector; using OffsetContainerT = typename ShM::vector; using RangeT = osrm::range; - friend std::ostream& operator<< <>(std::ostream &out, const RangeTable &table); - friend std::istream& operator>> <>(std::istream &in, RangeTable &table); + friend std::ostream &operator<<<>(std::ostream &out, const RangeTable &table); + friend std::istream &operator>><>(std::istream &in, RangeTable &table); RangeTable() : sum_lengths(0) {} // for loading from shared memory - explicit RangeTable(OffsetContainerT& external_offsets, BlockContainerT& external_blocks, const unsigned sum_lengths) - : sum_lengths(sum_lengths) + explicit RangeTable(OffsetContainerT &external_offsets, + BlockContainerT &external_blocks, + const unsigned sum_lengths) + : sum_lengths(sum_lengths) { block_offsets.swap(external_offsets); diff_blocks.swap(external_blocks); } // construct table from length vector - explicit RangeTable(const std::vector& lengths) + explicit RangeTable(const std::vector &lengths) { - const unsigned number_of_blocks = [&lengths]() { + const unsigned number_of_blocks = [&lengths]() + { unsigned num = (lengths.size() + 1) / (BLOCK_SIZE + 1); if ((lengths.size() + 1) % (BLOCK_SIZE + 1) != 0) { @@ -116,8 +117,8 @@ public: block_sum += last_length; } - BOOST_ASSERT((block_idx == 0 && block_offsets[block_counter] == lengths_prefix_sum) - || lengths_prefix_sum == (block_offsets[block_counter]+block_sum)); + BOOST_ASSERT((block_idx == 0 && block_offsets[block_counter] == lengths_prefix_sum) || + lengths_prefix_sum == (block_offsets[block_counter] + block_sum)); // block is full if (BLOCK_SIZE == block_idx) @@ -136,7 +137,7 @@ public: } // Last block can't be finished because we didn't add the sentinel - BOOST_ASSERT (block_counter == (number_of_blocks - 1)); + BOOST_ASSERT(block_counter == (number_of_blocks - 1)); // one block missing: starts with guard value if (0 == block_idx) @@ -155,7 +156,8 @@ public: } diff_blocks.push_back(block); - BOOST_ASSERT(diff_blocks.size() == number_of_blocks && block_offsets.size() == number_of_blocks); + BOOST_ASSERT(diff_blocks.size() == number_of_blocks && + block_offsets.size() == number_of_blocks); sum_lengths = lengths_prefix_sum; } @@ -172,7 +174,7 @@ public: unsigned begin_idx = 0; unsigned end_idx = 0; begin_idx = block_offsets[block_idx]; - const BlockT& block = diff_blocks[block_idx]; + const BlockT &block = diff_blocks[block_idx]; if (internal_idx > 0) { begin_idx += PrefixSumAtIndex(internal_idx - 1, block); @@ -195,9 +197,9 @@ public: return osrm::irange(begin_idx, end_idx); } -private: - inline unsigned PrefixSumAtIndex(int index, const BlockT& block) const; + private: + inline unsigned PrefixSumAtIndex(int index, const BlockT &block) const; // contains offset for each differential block OffsetContainerT block_offsets; @@ -206,8 +208,9 @@ private: unsigned sum_lengths; }; -template -unsigned RangeTable::PrefixSumAtIndex(int index, const BlockT& block) const +template +unsigned RangeTable::PrefixSumAtIndex(int index, + const BlockT &block) const { // this loop looks inefficent, but a modern compiler // will emit nice SIMD here, at least for sensible block sizes. (I checked.) @@ -220,39 +223,39 @@ unsigned RangeTable::PrefixSumAtIndex(int index, return sum; } -template -std::ostream& operator<<(std::ostream &out, const RangeTable &table) +template +std::ostream &operator<<(std::ostream &out, const RangeTable &table) { // write number of block const unsigned number_of_blocks = table.diff_blocks.size(); - out.write((char *) &number_of_blocks, sizeof(unsigned)); + out.write((char *)&number_of_blocks, sizeof(unsigned)); // write total length - out.write((char *) &table.sum_lengths, sizeof(unsigned)); + out.write((char *)&table.sum_lengths, sizeof(unsigned)); // write block offsets - out.write((char *) table.block_offsets.data(), sizeof(unsigned) * table.block_offsets.size()); + out.write((char *)table.block_offsets.data(), sizeof(unsigned) * table.block_offsets.size()); // write blocks - out.write((char *) table.diff_blocks.data(), BLOCK_SIZE * table.diff_blocks.size()); + out.write((char *)table.diff_blocks.data(), BLOCK_SIZE * table.diff_blocks.size()); return out; } -template -std::istream& operator>>(std::istream &in, RangeTable &table) +template +std::istream &operator>>(std::istream &in, RangeTable &table) { // read number of block unsigned number_of_blocks; - in.read((char *) &number_of_blocks, sizeof(unsigned)); + in.read((char *)&number_of_blocks, sizeof(unsigned)); // read total length - in.read((char *) &table.sum_lengths, sizeof(unsigned)); + in.read((char *)&table.sum_lengths, sizeof(unsigned)); table.block_offsets.resize(number_of_blocks); table.diff_blocks.resize(number_of_blocks); // read block offsets - in.read((char *) table.block_offsets.data(), sizeof(unsigned) * number_of_blocks); + in.read((char *)table.block_offsets.data(), sizeof(unsigned) * number_of_blocks); // read blocks - in.read((char *) table.diff_blocks.data(), BLOCK_SIZE * number_of_blocks); + in.read((char *)table.diff_blocks.data(), BLOCK_SIZE * number_of_blocks); return in; } -#endif //RANGE_TABLE_HPP +#endif // RANGE_TABLE_HPP diff --git a/data_structures/restriction_map.hpp b/data_structures/restriction_map.hpp index 41eb17a8c..a11b987f2 100644 --- a/data_structures/restriction_map.hpp +++ b/data_structures/restriction_map.hpp @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RESTRICTION_MAP_HPP #include "restriction.hpp" -#include "../Util/std_hash.hpp" +#include "../util/std_hash.hpp" #include "../typedefs.h" #include @@ -44,9 +44,7 @@ struct RestrictionSource NodeID start_node; NodeID via_node; - RestrictionSource(NodeID start, NodeID via) : start_node(start), via_node(via) - { - } + RestrictionSource(NodeID start, NodeID via) : start_node(start), via_node(via) {} friend inline bool operator==(const RestrictionSource &lhs, const RestrictionSource &rhs) { @@ -59,9 +57,7 @@ struct RestrictionTarget NodeID target_node; bool is_only; - explicit RestrictionTarget(NodeID target, bool only) : target_node(target), is_only(only) - { - } + explicit RestrictionTarget(NodeID target, bool only) : target_node(target), is_only(only) {} friend inline bool operator==(const RestrictionTarget &lhs, const RestrictionTarget &rhs) { @@ -98,7 +94,7 @@ class RestrictionMap RestrictionMap(const std::vector &restriction_list); // Replace end v with w in each turn restriction containing u as via node - template + template void FixupArrivingTurnRestriction(const NodeID node_u, const NodeID node_v, const NodeID node_w, @@ -148,24 +144,18 @@ class RestrictionMap bool IsViaNode(const NodeID node) const; - // Replaces start edge (v, w) with (u, w). Only start node changes. - void FixupStartingTurnRestriction(const NodeID node_u, - const NodeID node_v, - const NodeID node_w); + void + FixupStartingTurnRestriction(const NodeID node_u, const NodeID node_v, const NodeID node_w); // Check if edge (u, v) is the start of any turn restriction. // If so returns id of first target node. NodeID CheckForEmanatingIsOnlyTurn(const NodeID node_u, const NodeID node_v) const; // Checks if turn is actually a turn restriction. - bool CheckIfTurnIsRestricted(const NodeID node_u, - const NodeID node_v, - const NodeID node_w) const; + bool + CheckIfTurnIsRestricted(const NodeID node_u, const NodeID node_v, const NodeID node_w) const; - std::size_t size() - { - return m_count; - } + std::size_t size() { return m_count; } private: // check of node is the start of any restriction @@ -182,4 +172,4 @@ class RestrictionMap std::unordered_set m_no_turn_via_node_set; }; -#endif //RESTRICTION_MAP_HPP +#endif // RESTRICTION_MAP_HPP diff --git a/data_structures/shared_memory_factory.hpp b/data_structures/shared_memory_factory.hpp index dc714a68b..56e458ff1 100644 --- a/data_structures/shared_memory_factory.hpp +++ b/data_structures/shared_memory_factory.hpp @@ -28,8 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SHARED_MEMORY_FACTORY_HPP #define SHARED_MEMORY_FACTORY_HPP -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" #include #include @@ -123,8 +123,8 @@ class SharedMemory { Remove(key); } - shm = boost::interprocess::xsi_shared_memory( - boost::interprocess::open_or_create, key, size); + shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_or_create, key, + size); #ifdef __linux__ if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, 0)) { @@ -150,7 +150,10 @@ class SharedMemory boost::interprocess::xsi_key key(lock_file().string().c_str(), id); result = RegionExists(key); } - catch (...) { result = false; } + catch (...) + { + result = false; + } return result; } @@ -165,8 +168,14 @@ class SharedMemory static bool RegionExists(const boost::interprocess::xsi_key &key) { bool result = true; - try { boost::interprocess::xsi_shared_memory shm(boost::interprocess::open_only, key); } - catch (...) { result = false; } + try + { + boost::interprocess::xsi_shared_memory shm(boost::interprocess::open_only, key); + } + catch (...) + { + result = false; + } return result; } @@ -198,12 +207,12 @@ class SharedMemory // Windows - specific code class SharedMemory { - SharedMemory(const SharedMemory&) = delete; + SharedMemory(const SharedMemory &) = delete; // Remove shared memory on destruction class shm_remove { private: - shm_remove(const shm_remove&) = delete; + shm_remove(const shm_remove &) = delete; char *m_shmid; bool m_initialized; @@ -242,8 +251,7 @@ class SharedMemory if (0 == size) { // read_only shm = boost::interprocess::shared_memory_object( - boost::interprocess::open_only, - key, + boost::interprocess::open_only, key, read_write ? boost::interprocess::read_write : boost::interprocess::read_only); region = boost::interprocess::mapped_region( shm, read_write ? boost::interprocess::read_write : boost::interprocess::read_only); @@ -255,8 +263,8 @@ class SharedMemory { Remove(key); } - shm = boost::interprocess::shared_memory_object( - boost::interprocess::open_or_create, key, boost::interprocess::read_write); + shm = boost::interprocess::shared_memory_object(boost::interprocess::open_or_create, + key, boost::interprocess::read_write); shm.truncate(size); region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write); @@ -274,7 +282,10 @@ class SharedMemory build_key(id, k); result = RegionExists(k); } - catch (...) { result = false; } + catch (...) + { + result = false; + } return result; } @@ -286,20 +297,20 @@ class SharedMemory } private: - static void build_key(int id, char *key) - { - sprintf(key, "%s.%d", "osrm.lock", id); - } + static void build_key(int id, char *key) { sprintf(key, "%s.%d", "osrm.lock", id); } static bool RegionExists(const char *key) { bool result = true; try { - boost::interprocess::shared_memory_object shm( - boost::interprocess::open_only, key, boost::interprocess::read_write); + boost::interprocess::shared_memory_object shm(boost::interprocess::open_only, key, + boost::interprocess::read_write); + } + catch (...) + { + result = false; } - catch (...) { result = false; } return result; } diff --git a/data_structures/static_graph.hpp b/data_structures/static_graph.hpp index 05d65eeee..1358027f7 100644 --- a/data_structures/static_graph.hpp +++ b/data_structures/static_graph.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "percent.hpp" #include "shared_memory_vector_wrapper.hpp" -#include "../Util/integer_range.hpp" +#include "../util/integer_range.hpp" #include "../typedefs.h" #include @@ -57,8 +57,11 @@ template class StaticGraph NodeIterator target; EdgeDataT data; - template - InputEdge(NodeIterator source, NodeIterator target, Ts &&...data) : source(source), target(target), data(std::forward(data)...) { } + template + InputEdge(NodeIterator source, NodeIterator target, Ts &&... data) + : source(source), target(target), data(std::forward(data)...) + { + } bool operator<(const InputEdge &right) const { if (source != right.source) @@ -94,7 +97,7 @@ template class StaticGraph node_array.resize(number_of_nodes + 1); EdgeIterator edge = 0; EdgeIterator position = 0; - for (const auto node : osrm::irange(0u, number_of_nodes+1)) + for (const auto node : osrm::irange(0u, number_of_nodes + 1)) { EdgeIterator last_edge = edge; while (edge < number_of_edges && graph[edge].source == node) diff --git a/data_structures/static_rtree.hpp b/data_structures/static_rtree.hpp index 8ab7fe4c1..5eaf64768 100644 --- a/data_structures/static_rtree.hpp +++ b/data_structures/static_rtree.hpp @@ -37,12 +37,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "shared_memory_vector_wrapper.hpp" #include "upper_bound.hpp" -#include "../Util/floating_point.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/mercator.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/timing_util.hpp" +#include "../util/floating_point.hpp" +#include "../util/integer_range.hpp" +#include "../util/mercator.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" +#include "../util/timing_util.hpp" #include "../typedefs.h" #include @@ -69,8 +69,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. template , bool UseSharedMemory = false, - uint32_t BRANCHING_FACTOR=64, - uint32_t LEAF_NODE_SIZE=1024> + uint32_t BRANCHING_FACTOR = 64, + uint32_t LEAF_NODE_SIZE = 1024> class StaticRTree { public: @@ -87,19 +87,15 @@ class StaticRTree { for (uint32_t i = 0; i < element_count; ++i) { - min_lon = std::min(min_lon, - std::min(coordinate_list.at(objects[i].u).lon, - coordinate_list.at(objects[i].v).lon)); - max_lon = std::max(max_lon, - std::max(coordinate_list.at(objects[i].u).lon, - coordinate_list.at(objects[i].v).lon)); + min_lon = std::min(min_lon, std::min(coordinate_list.at(objects[i].u).lon, + coordinate_list.at(objects[i].v).lon)); + max_lon = std::max(max_lon, std::max(coordinate_list.at(objects[i].u).lon, + coordinate_list.at(objects[i].v).lon)); - min_lat = std::min(min_lat, - std::min(coordinate_list.at(objects[i].u).lat, - coordinate_list.at(objects[i].v).lat)); - max_lat = std::max(max_lat, - std::max(coordinate_list.at(objects[i].u).lat, - coordinate_list.at(objects[i].v).lat)); + min_lat = std::min(min_lat, std::min(coordinate_list.at(objects[i].u).lat, + coordinate_list.at(objects[i].v).lat)); + max_lat = std::max(max_lat, std::max(coordinate_list.at(objects[i].u).lat, + coordinate_list.at(objects[i].v).lat)); } BOOST_ASSERT(min_lat != std::numeric_limits::min()); BOOST_ASSERT(min_lon != std::numeric_limits::min()); @@ -150,58 +146,66 @@ class StaticRTree enum Direction { - INVALID = 0, - NORTH = 1, - SOUTH = 2, - EAST = 4, + INVALID = 0, + NORTH = 1, + SOUTH = 2, + EAST = 4, NORTH_EAST = 5, SOUTH_EAST = 6, - WEST = 8, + WEST = 8, NORTH_WEST = 9, SOUTH_WEST = 10 }; Direction d = INVALID; if (location.lat > max_lat) - d = (Direction) (d | NORTH); + d = (Direction)(d | NORTH); else if (location.lat < min_lat) - d = (Direction) (d | SOUTH); + d = (Direction)(d | SOUTH); if (location.lon > max_lon) - d = (Direction) (d | EAST); + d = (Direction)(d | EAST); else if (location.lon < min_lon) - d = (Direction) (d | WEST); + d = (Direction)(d | WEST); BOOST_ASSERT(d != INVALID); float min_dist = std::numeric_limits::max(); switch (d) { - case NORTH: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(max_lat, location.lon)); - break; - case SOUTH: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(min_lat, location.lon)); - break; - case WEST: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(location.lat, min_lon)); - break; - case EAST: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(location.lat, max_lon)); - break; - case NORTH_EAST: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(max_lat, max_lon)); - break; - case NORTH_WEST: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(max_lat, min_lon)); - break; - case SOUTH_EAST: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(min_lat, max_lon)); - break; - case SOUTH_WEST: - min_dist = coordinate_calculation::euclidean_distance(location, FixedPointCoordinate(min_lat, min_lon)); - break; - default: - break; + case NORTH: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(max_lat, location.lon)); + break; + case SOUTH: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(min_lat, location.lon)); + break; + case WEST: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(location.lat, min_lon)); + break; + case EAST: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(location.lat, max_lon)); + break; + case NORTH_EAST: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(max_lat, max_lon)); + break; + case NORTH_WEST: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(max_lat, min_lon)); + break; + case SOUTH_EAST: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(min_lat, max_lon)); + break; + case SOUTH_WEST: + min_dist = coordinate_calculation::euclidean_distance( + location, FixedPointCoordinate(min_lat, min_lon)); + break; + default: + break; } BOOST_ASSERT(min_dist != std::numeric_limits::max()); @@ -220,15 +224,13 @@ class StaticRTree min_max_dist = std::min( min_max_dist, - std::max( - coordinate_calculation::euclidean_distance(location, upper_left), - coordinate_calculation::euclidean_distance(location, upper_right))); + std::max(coordinate_calculation::euclidean_distance(location, upper_left), + coordinate_calculation::euclidean_distance(location, upper_right))); min_max_dist = std::min( min_max_dist, - std::max( - coordinate_calculation::euclidean_distance(location, upper_right), - coordinate_calculation::euclidean_distance(location, lower_right))); + std::max(coordinate_calculation::euclidean_distance(location, upper_right), + coordinate_calculation::euclidean_distance(location, lower_right))); min_max_dist = std::min( min_max_dist, @@ -378,7 +380,8 @@ class StaticRTree FixedPointCoordinate(coordinate_list.at(current_element.v).lat, coordinate_list.at(current_element.v).lon)); current_centroid.lat = - COORDINATE_PRECISION * mercator::lat2y(current_centroid.lat / COORDINATE_PRECISION); + COORDINATE_PRECISION * + mercator::lat2y(current_centroid.lat / COORDINATE_PRECISION); current_wrapper.m_hilbert_value = get_hilbert_number(current_centroid); } @@ -416,8 +419,8 @@ 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, coordinate_list); + InitializeMBRectangle(current_node.minimum_bounding_rectangle, current_leaf.objects, + current_leaf.object_count, 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); @@ -440,8 +443,7 @@ class StaticRTree TreeNode parent_node; // pack BRANCHING_FACTOR elements into tree_nodes each for (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()) { @@ -474,17 +476,17 @@ class StaticRTree tbb::parallel_for(tbb::blocked_range(0, search_tree_size), [this, &search_tree_size](const tbb::blocked_range &range) { - for (uint32_t i = range.begin(); i != range.end(); ++i) - { - TreeNode ¤t_tree_node = this->m_search_tree[i]; - for (uint32_t j = 0; j < current_tree_node.child_count; ++j) - { - const uint32_t old_id = current_tree_node.children[j]; - const uint32_t new_id = search_tree_size - old_id - 1; - current_tree_node.children[j] = new_id; - } - } - }); + for (uint32_t i = range.begin(); i != range.end(); ++i) + { + TreeNode ¤t_tree_node = this->m_search_tree[i]; + for (uint32_t j = 0; j < current_tree_node.child_count; ++j) + { + const uint32_t old_id = current_tree_node.children[j]; + const 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); @@ -606,12 +608,10 @@ class StaticRTree continue; } - float current_minimum_distance = - coordinate_calculation::euclidean_distance( - input_coordinate.lat, - input_coordinate.lon, - m_coordinate_list->at(current_edge.u).lat, - m_coordinate_list->at(current_edge.u).lon); + float current_minimum_distance = coordinate_calculation::euclidean_distance( + input_coordinate.lat, input_coordinate.lon, + m_coordinate_list->at(current_edge.u).lat, + m_coordinate_list->at(current_edge.u).lon); if (current_minimum_distance < min_dist) { // found a new minimum @@ -619,12 +619,10 @@ class StaticRTree result_coordinate = m_coordinate_list->at(current_edge.u); } - current_minimum_distance = - coordinate_calculation::euclidean_distance( - input_coordinate.lat, - input_coordinate.lon, - m_coordinate_list->at(current_edge.v).lat, - m_coordinate_list->at(current_edge.v).lon); + current_minimum_distance = coordinate_calculation::euclidean_distance( + input_coordinate.lat, input_coordinate.lon, + m_coordinate_list->at(current_edge.v).lat, + m_coordinate_list->at(current_edge.v).lon); if (current_minimum_distance < min_dist) { @@ -636,27 +634,23 @@ class StaticRTree } else { - min_max_dist = ExploreTreeNode(current_tree_node, - input_coordinate, - min_dist, - min_max_dist, - traversal_queue); + min_max_dist = ExploreTreeNode(current_tree_node, input_coordinate, min_dist, + min_max_dist, traversal_queue); } } } return result_coordinate.is_valid(); } - // implementation of the Hjaltason/Samet query [3], a BFS traversal of the tree // - searches for k elements nearest elements // - continues to find the k+1st element from a big component if k elements // come from tiny components - bool - IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, - std::vector &result_phantom_node_vector, - const unsigned max_number_of_phantom_nodes, - const unsigned max_checked_elements = 4*LEAF_NODE_SIZE) + bool IncrementalFindPhantomNodeForCoordinate( + const FixedPointCoordinate &input_coordinate, + std::vector &result_phantom_node_vector, + const unsigned max_number_of_phantom_nodes, + const unsigned max_checked_elements = 4 * LEAF_NODE_SIZE) { unsigned inspected_elements = 0; unsigned number_of_elements_from_big_cc = 0; @@ -664,9 +658,9 @@ class StaticRTree unsigned pruned_elements = 0; - std::pair projected_coordinate = - { mercator::lat2y(input_coordinate.lat / COORDINATE_PRECISION), - input_coordinate.lon / COORDINATE_PRECISION }; + std::pair projected_coordinate = { + mercator::lat2y(input_coordinate.lat / COORDINATE_PRECISION), + input_coordinate.lon / COORDINATE_PRECISION}; // upper bound pruning technique upper_bound pruning_bound(max_number_of_phantom_nodes); @@ -682,7 +676,8 @@ class StaticRTree if (current_query_node.node.template is()) { // current object is a tree node - const TreeNode & current_tree_node = current_query_node.node.template get(); + const TreeNode ¤t_tree_node = + current_query_node.node.template get(); if (current_tree_node.child_is_on_disk) { LeafNode current_leaf_node; @@ -692,11 +687,10 @@ class StaticRTree for (const auto i : osrm::irange(0u, current_leaf_node.object_count)) { const auto ¤t_edge = current_leaf_node.objects[i]; - const float current_perpendicular_distance = - coordinate_calculation::perpendicular_distance_from_projected_coordinate( + const float current_perpendicular_distance = coordinate_calculation:: + perpendicular_distance_from_projected_coordinate( m_coordinate_list->at(current_edge.u), - m_coordinate_list->at(current_edge.v), - input_coordinate, + m_coordinate_list->at(current_edge.v), input_coordinate, projected_coordinate); // distance must be non-negative BOOST_ASSERT(0.f <= current_perpendicular_distance); @@ -706,7 +700,9 @@ class StaticRTree { pruning_bound.insert(current_perpendicular_distance); traversal_queue.emplace(current_perpendicular_distance, current_edge); - } else { + } + else + { ++pruned_elements; } } @@ -718,8 +714,10 @@ class StaticRTree { const int32_t child_id = current_tree_node.children[i]; const TreeNode &child_tree_node = m_search_tree[child_id]; - const RectangleT &child_rectangle = child_tree_node.minimum_bounding_rectangle; - const float lower_bound_to_element = child_rectangle.GetMinDist(input_coordinate); + const RectangleT &child_rectangle = + child_tree_node.minimum_bounding_rectangle; + const float lower_bound_to_element = + child_rectangle.GetMinDist(input_coordinate); BOOST_ASSERT(0.f <= lower_bound_to_element); traversal_queue.emplace(lower_bound_to_element, child_tree_node); @@ -730,7 +728,8 @@ class StaticRTree { // current object is a leaf node ++inspected_elements; // inspecting an actual road segment - const EdgeDataT & current_segment = current_query_node.node.template get(); + const EdgeDataT ¤t_segment = + current_query_node.node.template get(); // continue searching for the first segment from a big component if (number_of_elements_from_big_cc == 0 && @@ -744,29 +743,20 @@ class StaticRTree float current_ratio = 0.f; FixedPointCoordinate foot_point_coordinate_on_segment; // const float current_perpendicular_distance = - coordinate_calculation::perpendicular_distance_from_projected_coordinate( - m_coordinate_list->at(current_segment.u), - m_coordinate_list->at(current_segment.v), - input_coordinate, - projected_coordinate, - foot_point_coordinate_on_segment, - current_ratio); + coordinate_calculation::perpendicular_distance_from_projected_coordinate( + m_coordinate_list->at(current_segment.u), + m_coordinate_list->at(current_segment.v), input_coordinate, + projected_coordinate, foot_point_coordinate_on_segment, current_ratio); // store phantom node in result vector result_phantom_node_vector.emplace_back( current_segment.forward_edge_based_node_id, - current_segment.reverse_edge_based_node_id, - current_segment.name_id, - current_segment.forward_weight, - current_segment.reverse_weight, - current_segment.forward_offset, - current_segment.reverse_offset, - current_segment.packed_geometry_id, - current_segment.component_id, - foot_point_coordinate_on_segment, - current_segment.fwd_segment_position, - current_segment.forward_travel_mode, - current_segment.backward_travel_mode); + current_segment.reverse_edge_based_node_id, current_segment.name_id, + current_segment.forward_weight, current_segment.reverse_weight, + current_segment.forward_offset, current_segment.reverse_offset, + current_segment.packed_geometry_id, current_segment.component_id, + foot_point_coordinate_on_segment, current_segment.fwd_segment_position, + current_segment.forward_travel_mode, current_segment.backward_travel_mode); // Hack to fix rounding errors and wandering via nodes. FixUpRoundingIssue(input_coordinate, result_phantom_node_vector.back()); @@ -787,16 +777,20 @@ class StaticRTree } // stop the search by flushing the queue - if ((result_phantom_node_vector.size() >= max_number_of_phantom_nodes && number_of_elements_from_big_cc > 0) || + if ((result_phantom_node_vector.size() >= max_number_of_phantom_nodes && + number_of_elements_from_big_cc > 0) || inspected_elements >= max_checked_elements) { traversal_queue = std::priority_queue{}; } } - // SimpleLogger().Write() << "result_phantom_node_vector.size(): " << result_phantom_node_vector.size(); + // SimpleLogger().Write() << "result_phantom_node_vector.size(): " << + // result_phantom_node_vector.size(); // SimpleLogger().Write() << "max_number_of_phantom_nodes: " << max_number_of_phantom_nodes; - // SimpleLogger().Write() << "number_of_elements_from_big_cc: " << number_of_elements_from_big_cc; - // SimpleLogger().Write() << "number_of_elements_from_tiny_cc: " << number_of_elements_from_tiny_cc; + // SimpleLogger().Write() << "number_of_elements_from_big_cc: " << + // number_of_elements_from_big_cc; + // SimpleLogger().Write() << "number_of_elements_from_tiny_cc: " << + // number_of_elements_from_tiny_cc; // SimpleLogger().Write() << "inspected_elements: " << inspected_elements; // SimpleLogger().Write() << "max_checked_elements: " << max_checked_elements; // SimpleLogger().Write() << "pruned_elements: " << pruned_elements; @@ -805,13 +799,14 @@ class StaticRTree } // implementation of the Hjaltason/Samet query [3], a BFS traversal of the tree - bool - IncrementalFindPhantomNodeForCoordinateWithDistance(const FixedPointCoordinate &input_coordinate, - std::vector> &result_phantom_node_vector, - const unsigned number_of_results, - const unsigned max_checked_segments = 4*LEAF_NODE_SIZE) + bool IncrementalFindPhantomNodeForCoordinateWithDistance( + const FixedPointCoordinate &input_coordinate, + std::vector> &result_phantom_node_vector, + const unsigned number_of_results, + const unsigned max_checked_segments = 4 * LEAF_NODE_SIZE) { - std::vector min_found_distances(number_of_results, std::numeric_limits::max()); + std::vector min_found_distances(number_of_results, + std::numeric_limits::max()); unsigned number_of_results_found_in_big_cc = 0; unsigned number_of_results_found_in_tiny_cc = 0; @@ -827,7 +822,7 @@ class StaticRTree const IncrementalQueryCandidate current_query_node = traversal_queue.top(); traversal_queue.pop(); - const float current_min_dist = min_found_distances[number_of_results-1]; + const float current_min_dist = min_found_distances[number_of_results - 1]; if (current_query_node.min_dist > current_min_dist) { @@ -836,7 +831,8 @@ class StaticRTree if (current_query_node.RepresentsTreeNode()) { - const TreeNode & current_tree_node = current_query_node.node.template get(); + const TreeNode ¤t_tree_node = + current_query_node.node.template get(); if (current_tree_node.child_is_on_disk) { LeafNode current_leaf_node; @@ -848,8 +844,7 @@ class StaticRTree const float current_perpendicular_distance = coordinate_calculation::perpendicular_distance( m_coordinate_list->at(current_edge.u), - m_coordinate_list->at(current_edge.v), - input_coordinate); + m_coordinate_list->at(current_edge.v), input_coordinate); // distance must be non-negative BOOST_ASSERT(0. <= current_perpendicular_distance); @@ -866,8 +861,10 @@ class StaticRTree { const int32_t child_id = current_tree_node.children[i]; const TreeNode &child_tree_node = m_search_tree[child_id]; - const RectangleT &child_rectangle = child_tree_node.minimum_bounding_rectangle; - const float lower_bound_to_element = child_rectangle.GetMinDist(input_coordinate); + const RectangleT &child_rectangle = + child_tree_node.minimum_bounding_rectangle; + const float lower_bound_to_element = + child_rectangle.GetMinDist(input_coordinate); // TODO - enough elements found, i.e. nearest distance > maximum distance? // ie. some measure of 'confidence of accuracy' @@ -878,23 +875,27 @@ class StaticRTree traversal_queue.emplace(lower_bound_to_element, child_tree_node); } } - // SimpleLogger().Write(logDEBUG) << "added " << current_tree_node.child_count << " mbrs into queue of " << traversal_queue.size(); + // SimpleLogger().Write(logDEBUG) << "added " << current_tree_node.child_count + // << " mbrs into queue of " << traversal_queue.size(); } } else { ++inspected_segments; // inspecting an actual road segment - const EdgeDataT & current_segment = current_query_node.node.template get(); + const EdgeDataT ¤t_segment = + current_query_node.node.template get(); // don't collect too many results from small components - if (number_of_results_found_in_big_cc == number_of_results && !current_segment.is_in_tiny_cc) + if (number_of_results_found_in_big_cc == number_of_results && + !current_segment.is_in_tiny_cc) { continue; } // don't collect too many results from big components - if (number_of_results_found_in_tiny_cc == number_of_results && current_segment.is_in_tiny_cc) + if (number_of_results_found_in_tiny_cc == number_of_results && + current_segment.is_in_tiny_cc) { continue; } @@ -905,10 +906,8 @@ class StaticRTree const float current_perpendicular_distance = coordinate_calculation::perpendicular_distance( m_coordinate_list->at(current_segment.u), - m_coordinate_list->at(current_segment.v), - input_coordinate, - foot_point_coordinate_on_segment, - current_ratio); + m_coordinate_list->at(current_segment.v), input_coordinate, + foot_point_coordinate_on_segment, current_ratio); BOOST_ASSERT(0. <= current_perpendicular_distance); @@ -918,16 +917,11 @@ class StaticRTree // store phantom node in result vector result_phantom_node_vector.emplace_back( current_segment.forward_edge_based_node_id, - current_segment.reverse_edge_based_node_id, - current_segment.name_id, - current_segment.forward_weight, - current_segment.reverse_weight, - current_segment.forward_offset, - current_segment.reverse_offset, - current_segment.packed_geometry_id, - foot_point_coordinate_on_segment, - current_segment.fwd_segment_position, - current_perpendicular_distance); + current_segment.reverse_edge_based_node_id, current_segment.name_id, + current_segment.forward_weight, current_segment.reverse_weight, + current_segment.forward_offset, current_segment.reverse_offset, + current_segment.packed_geometry_id, foot_point_coordinate_on_segment, + current_segment.fwd_segment_position, current_perpendicular_distance); // Hack to fix rounding errors and wandering via nodes. FixUpRoundingIssue(input_coordinate, result_phantom_node_vector.back()); @@ -944,17 +938,22 @@ class StaticRTree else { // found an element in a large component - min_found_distances[number_of_results_found_in_big_cc] = current_perpendicular_distance; + min_found_distances[number_of_results_found_in_big_cc] = + current_perpendicular_distance; ++number_of_results_found_in_big_cc; - // SimpleLogger().Write(logDEBUG) << std::setprecision(8) << foot_point_coordinate_on_segment << " at " << current_perpendicular_distance; + // SimpleLogger().Write(logDEBUG) << std::setprecision(8) << + // foot_point_coordinate_on_segment << " at " << + // current_perpendicular_distance; } } } // TODO add indicator to prune if maxdist > threshold - if (number_of_results == number_of_results_found_in_big_cc || inspected_segments >= max_checked_segments) + if (number_of_results == number_of_results_found_in_big_cc || + inspected_segments >= max_checked_segments) { - // SimpleLogger().Write(logDEBUG) << "flushing queue of " << traversal_queue.size() << " elements"; + // SimpleLogger().Write(logDEBUG) << "flushing queue of " << traversal_queue.size() + // << " elements"; // work-around for traversal_queue.clear(); traversal_queue = std::priority_queue{}; } @@ -963,8 +962,6 @@ class StaticRTree return !result_phantom_node_vector.empty(); } - - bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, PhantomNode &result_phantom_node, const unsigned zoom_level) @@ -1005,9 +1002,7 @@ class StaticRTree const float current_perpendicular_distance = coordinate_calculation::perpendicular_distance( m_coordinate_list->at(current_edge.u), - m_coordinate_list->at(current_edge.v), - input_coordinate, - nearest, + m_coordinate_list->at(current_edge.v), input_coordinate, nearest, current_ratio); BOOST_ASSERT(0. <= current_perpendicular_distance); @@ -1035,11 +1030,8 @@ class StaticRTree } else { - min_max_dist = ExploreTreeNode(current_tree_node, - input_coordinate, - min_dist, - min_max_dist, - traversal_queue); + min_max_dist = ExploreTreeNode(current_tree_node, input_coordinate, min_dist, + min_max_dist, traversal_queue); } } } @@ -1056,8 +1048,7 @@ class StaticRTree } private: - - inline void SetForwardAndReverseWeightsOnPhantomNode(const EdgeDataT & nearest_edge, + inline void SetForwardAndReverseWeightsOnPhantomNode(const EdgeDataT &nearest_edge, PhantomNode &result_phantom_node) const { const float distance_1 = coordinate_calculation::euclidean_distance( @@ -1069,32 +1060,34 @@ class StaticRTree using TreeWeightType = decltype(result_phantom_node.forward_weight); static_assert(std::is_same::value, - "forward and reverse weight type in tree must be the same"); + "forward and reverse weight type in tree must be the same"); if (SPECIAL_NODEID != result_phantom_node.forward_node_id) { - const auto new_weight = static_cast(result_phantom_node.forward_weight * ratio); + const auto new_weight = + static_cast(result_phantom_node.forward_weight * ratio); result_phantom_node.forward_weight = new_weight; } if (SPECIAL_NODEID != result_phantom_node.reverse_node_id) { - const auto new_weight = static_cast(result_phantom_node.reverse_weight * (1.f-ratio)); + const auto new_weight = + static_cast(result_phantom_node.reverse_weight * (1.f - ratio)); result_phantom_node.reverse_weight = new_weight; } } // fixup locations if too close to inputs inline void FixUpRoundingIssue(const FixedPointCoordinate &input_coordinate, - PhantomNode &result_phantom_node) const + PhantomNode &result_phantom_node) const { - if (1 == std::abs(input_coordinate.lon - result_phantom_node.location.lon)) - { - result_phantom_node.location.lon = input_coordinate.lon; - } - if (1 == std::abs(input_coordinate.lat - result_phantom_node.location.lat)) - { - result_phantom_node.location.lat = input_coordinate.lat; - } + if (1 == std::abs(input_coordinate.lon - result_phantom_node.location.lon)) + { + result_phantom_node.location.lon = input_coordinate.lon; + } + if (1 == std::abs(input_coordinate.lat - result_phantom_node.location.lat)) + { + result_phantom_node.location.lat = input_coordinate.lat; + } } template @@ -1140,8 +1133,7 @@ class StaticRTree } const uint64_t seek_pos = sizeof(uint64_t) + leaf_id * sizeof(LeafNode); leaves_stream.seekg(seek_pos); - BOOST_ASSERT_MSG(leaves_stream.good(), - "Seeking to position in leaf file failed."); + BOOST_ASSERT_MSG(leaves_stream.good(), "Seeking to position in leaf file failed."); leaves_stream.read((char *)&result_node, sizeof(LeafNode)); BOOST_ASSERT_MSG(leaves_stream.good(), "Reading from leaf file failed."); } @@ -1154,26 +1146,26 @@ class StaticRTree return (a == b && c == d) || (a == c && b == d) || (a == d && b == c); } - inline void InitializeMBRectangle(RectangleT& rectangle, + inline void InitializeMBRectangle(RectangleT &rectangle, const std::array &objects, const uint32_t element_count, const std::vector &coordinate_list) { for (uint32_t i = 0; i < element_count; ++i) { - rectangle.min_lon = std::min(rectangle.min_lon, - std::min(coordinate_list.at(objects[i].u).lon, - coordinate_list.at(objects[i].v).lon)); - rectangle.max_lon = std::max(rectangle.max_lon, - std::max(coordinate_list.at(objects[i].u).lon, - coordinate_list.at(objects[i].v).lon)); + rectangle.min_lon = + std::min(rectangle.min_lon, std::min(coordinate_list.at(objects[i].u).lon, + coordinate_list.at(objects[i].v).lon)); + rectangle.max_lon = + std::max(rectangle.max_lon, std::max(coordinate_list.at(objects[i].u).lon, + coordinate_list.at(objects[i].v).lon)); - rectangle.min_lat = std::min(rectangle.min_lat, - std::min(coordinate_list.at(objects[i].u).lat, - coordinate_list.at(objects[i].v).lat)); - rectangle.max_lat = std::max(rectangle.max_lat, - std::max(coordinate_list.at(objects[i].u).lat, - coordinate_list.at(objects[i].v).lat)); + rectangle.min_lat = + std::min(rectangle.min_lat, std::min(coordinate_list.at(objects[i].u).lat, + coordinate_list.at(objects[i].v).lat)); + rectangle.max_lat = + std::max(rectangle.max_lat, std::max(coordinate_list.at(objects[i].u).lat, + coordinate_list.at(objects[i].v).lat)); } BOOST_ASSERT(rectangle.min_lat != std::numeric_limits::min()); BOOST_ASSERT(rectangle.min_lon != std::numeric_limits::min()); diff --git a/datastore.cpp b/datastore.cpp index bcb1d8b43..e701b4e89 100644 --- a/datastore.cpp +++ b/datastore.cpp @@ -36,11 +36,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "server/data_structures/datafacade_base.hpp" #include "server/data_structures/shared_datatype.hpp" #include "server/data_structures/shared_barriers.hpp" -#include "Util/boost_filesystem_2_fix.hpp" -#include "Util/datastore_options.hpp" -#include "Util/simple_logger.hpp" -#include "Util/osrm_exception.hpp" -#include "Util/fingerprint.hpp" +#include "util/boost_filesystem_2_fix.hpp" +#include "util/datastore_options.hpp" +#include "util/simple_logger.hpp" +#include "util/osrm_exception.hpp" +#include "util/fingerprint.hpp" #include "typedefs.h" #include diff --git a/descriptors/description_factory.cpp b/descriptors/description_factory.cpp index 5c19c34e5..034dc88ae 100644 --- a/descriptors/description_factory.cpp +++ b/descriptors/description_factory.cpp @@ -31,8 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/coordinate_calculation.hpp" #include "../data_structures/internal_route_result.hpp" #include "../data_structures/turn_instructions.hpp" -#include "../Util/container.hpp" -#include "../Util/integer_range.hpp" +#include "../util/container.hpp" +#include "../util/integer_range.hpp" #include "../typedefs.h" DescriptionFactory::DescriptionFactory() : entire_length(0) { via_indices.push_back(0); } diff --git a/descriptors/gpx_descriptor.hpp b/descriptors/gpx_descriptor.hpp index a6af9f8dc..bff2733e7 100644 --- a/descriptors/gpx_descriptor.hpp +++ b/descriptors/gpx_descriptor.hpp @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define GPX_DESCRIPTOR_HPP #include "descriptor_base.hpp" -#include "../Util/xml_renderer.hpp" +#include "../util/xml_renderer.hpp" #include diff --git a/descriptors/json_descriptor.hpp b/descriptors/json_descriptor.hpp index 79d4a3d1e..aceca1927 100644 --- a/descriptors/json_descriptor.hpp +++ b/descriptors/json_descriptor.hpp @@ -34,12 +34,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../algorithms/route_name_extraction.hpp" #include "../data_structures/segment_information.hpp" #include "../data_structures/turn_instructions.hpp" -#include "../Util/bearing.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/json_renderer.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/string_util.hpp" -#include "../Util/timing_util.hpp" +#include "../util/bearing.hpp" +#include "../util/integer_range.hpp" +#include "../util/json_renderer.hpp" +#include "../util/simple_logger.hpp" +#include "../util/string_util.hpp" +#include "../util/timing_util.hpp" #include diff --git a/extract.cpp b/extract.cpp index 9f496f115..b37518444 100644 --- a/extract.cpp +++ b/extract.cpp @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "extractor/extractor.hpp" #include "extractor/extractor_options.hpp" -#include "Util/simple_logger.hpp" +#include "util/simple_logger.hpp" int main(int argc, char *argv[]) { diff --git a/extractor/extraction_containers.cpp b/extractor/extraction_containers.cpp index 387f01d97..e40959d62 100644 --- a/extractor/extraction_containers.cpp +++ b/extractor/extraction_containers.cpp @@ -32,9 +32,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/node_id.hpp" #include "../data_structures/range_table.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/timing_util.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" +#include "../util/timing_util.hpp" #include #include diff --git a/extractor/extraction_containers.hpp b/extractor/extraction_containers.hpp index 588dcabb0..ec5b620ea 100644 --- a/extractor/extraction_containers.hpp +++ b/extractor/extraction_containers.hpp @@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "first_and_last_segment_of_way.hpp" #include "../data_structures/external_memory_node.hpp" #include "../data_structures/restriction.hpp" -#include "../Util/fingerprint.hpp" +#include "../util/fingerprint.hpp" #include diff --git a/extractor/extraction_helper_functions.hpp b/extractor/extraction_helper_functions.hpp index d2a73c9c9..ef840212b 100644 --- a/extractor/extraction_helper_functions.hpp +++ b/extractor/extraction_helper_functions.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2013, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef EXTRACTION_HELPER_FUNCTIONS_HPP #define EXTRACTION_HELPER_FUNCTIONS_HPP -#include "../Util/cast.hpp" +#include "../util/cast.hpp" #include #include diff --git a/extractor/extractor.cpp b/extractor/extractor.cpp index c4e7203f5..326a43e23 100644 --- a/extractor/extractor.cpp +++ b/extractor/extractor.cpp @@ -34,10 +34,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "restriction_parser.hpp" #include "scripting_environment.hpp" -#include "../Util/git_sha.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/timing_util.hpp" +#include "../util/git_sha.hpp" +#include "../util/make_unique.hpp" +#include "../util/simple_logger.hpp" +#include "../util/timing_util.hpp" #include "../typedefs.h" diff --git a/extractor/extractor_callbacks.cpp b/extractor/extractor_callbacks.cpp index 361c7e5ce..2770cd918 100644 --- a/extractor/extractor_callbacks.cpp +++ b/extractor/extractor_callbacks.cpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -32,8 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/external_memory_node.hpp" #include "../data_structures/restriction.hpp" -#include "../Util/container.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/container.hpp" +#include "../util/simple_logger.hpp" #include diff --git a/extractor/extractor_options.cpp b/extractor/extractor_options.cpp index 68a905a22..12ac458fc 100644 --- a/extractor/extractor_options.cpp +++ b/extractor/extractor_options.cpp @@ -27,9 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "extractor_options.hpp" -#include "../Util/git_sha.hpp" -#include "../Util/ini_file.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/git_sha.hpp" +#include "../util/ini_file.hpp" +#include "../util/simple_logger.hpp" #include #include diff --git a/extractor/restriction_parser.cpp b/extractor/restriction_parser.cpp index 3cd53ffff..de73dda5f 100644 --- a/extractor/restriction_parser.cpp +++ b/extractor/restriction_parser.cpp @@ -30,9 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "scripting_environment.hpp" #include "../data_structures/external_memory_node.hpp" -#include "../Util/lua_util.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/lua_util.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" #include #include diff --git a/extractor/scripting_environment.cpp b/extractor/scripting_environment.cpp index d50161c12..45e4d0226 100644 --- a/extractor/scripting_environment.cpp +++ b/extractor/scripting_environment.cpp @@ -31,9 +31,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "extraction_node.hpp" #include "extraction_way.hpp" #include "../data_structures/external_memory_node.hpp" -#include "../Util/lua_util.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/lua_util.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" #include "../typedefs.h" #include diff --git a/library/osrm_impl.cpp b/library/osrm_impl.cpp index aaf1e3da3..aea85a44c 100644 --- a/library/osrm_impl.cpp +++ b/library/osrm_impl.cpp @@ -46,9 +46,9 @@ class named_mutex; #include "../server/data_structures/internal_datafacade.hpp" #include "../server/data_structures/shared_barriers.hpp" #include "../server/data_structures/shared_datafacade.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/routed_options.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/make_unique.hpp" +#include "../util/routed_options.hpp" +#include "../util/simple_logger.hpp" #include #include diff --git a/plugins/distance_table.hpp b/plugins/distance_table.hpp index e5ca5da5c..b7483f16f 100644 --- a/plugins/distance_table.hpp +++ b/plugins/distance_table.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DISTANCE_TABLE_PLUGIN_H -#define DISTANCE_TABLE_PLUGIN_H +#ifndef DISTANCE_TABLE_HPP +#define DISTANCE_TABLE_HPP #include "plugin_base.hpp" @@ -34,10 +34,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/query_edge.hpp" #include "../data_structures/search_engine.hpp" #include "../descriptors/descriptor_base.hpp" -#include "../Util/json_renderer.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/string_util.hpp" -#include "../Util/timing_util.hpp" +#include "../util/json_renderer.hpp" +#include "../util/make_unique.hpp" +#include "../util/string_util.hpp" +#include "../util/timing_util.hpp" #include @@ -56,8 +56,9 @@ template class DistanceTablePlugin final : public BasePlugin int max_locations_distance_table; public: - explicit DistanceTablePlugin(DataFacadeT *facade, const int max_locations_distance_table) : - max_locations_distance_table(max_locations_distance_table), descriptor_string("table"), facade(facade) + explicit DistanceTablePlugin(DataFacadeT *facade, const int max_locations_distance_table) + : max_locations_distance_table(max_locations_distance_table), descriptor_string("table"), + facade(facade) { search_engine_ptr = osrm::make_unique>(facade); } @@ -74,8 +75,9 @@ template class DistanceTablePlugin final : public BasePlugin } const bool checksum_OK = (route_parameters.check_sum == facade->GetCheckSum()); - unsigned max_locations = std::min(static_cast(max_locations_distance_table), - static_cast(route_parameters.coordinates.size())); + unsigned max_locations = + std::min(static_cast(max_locations_distance_table), + static_cast(route_parameters.coordinates.size())); PhantomNodeArray phantom_node_vector(max_locations); for (const auto i : osrm::irange(0u, max_locations)) @@ -92,8 +94,7 @@ template class DistanceTablePlugin final : public BasePlugin } } facade->IncrementalFindPhantomNodeForCoordinate(route_parameters.coordinates[i], - phantom_node_vector[i], - 1); + phantom_node_vector[i], 1); BOOST_ASSERT(phantom_node_vector[i].front().is_valid(facade->GetNumberOfNodes())); } @@ -128,4 +129,4 @@ template class DistanceTablePlugin final : public BasePlugin DataFacadeT *facade; }; -#endif // DISTANCE_TABLE_PLUGIN_H +#endif // DISTANCE_TABLE_HPP diff --git a/plugins/hello_world.hpp b/plugins/hello_world.hpp index d0f1e9092..97c03095b 100644 --- a/plugins/hello_world.hpp +++ b/plugins/hello_world.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -25,13 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HELLO_WORLD_PLUGIN_H -#define HELLO_WORLD_PLUGIN_H +#ifndef HELLO_WORLD_HPP +#define HELLO_WORLD_HPP #include "plugin_base.hpp" -#include "../Util/cast.hpp" -#include "../Util/json_renderer.hpp" +#include "../util/cast.hpp" +#include "../util/json_renderer.hpp" #include @@ -77,8 +77,10 @@ class HelloWorldPlugin final : public BasePlugin JSON::Object json_location; JSON::Array json_coordinates; - json_coordinates.values.push_back(static_cast(coordinate.lat / COORDINATE_PRECISION)); - json_coordinates.values.push_back(static_cast(coordinate.lon / COORDINATE_PRECISION)); + json_coordinates.values.push_back( + static_cast(coordinate.lat / COORDINATE_PRECISION)); + json_coordinates.values.push_back( + static_cast(coordinate.lon / COORDINATE_PRECISION)); json_location.values[cast::integral_to_string(counter)] = json_coordinates; json_locations.values.push_back(json_location); ++counter; @@ -101,4 +103,4 @@ class HelloWorldPlugin final : public BasePlugin std::string descriptor_string; }; -#endif // HELLO_WORLD_PLUGIN_H +#endif // HELLO_WORLD_HPP diff --git a/plugins/locate.hpp b/plugins/locate.hpp index 7092da9b0..262935a67 100644 --- a/plugins/locate.hpp +++ b/plugins/locate.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -25,13 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LOCATE_PLUGIN_H -#define LOCATE_PLUGIN_H +#ifndef LOCATE_HPP +#define LOCATE_HPP #include "plugin_base.hpp" -#include "../Util/json_renderer.hpp" -#include "../Util/string_util.hpp" +#include "../util/json_renderer.hpp" +#include "../util/string_util.hpp" #include @@ -47,7 +47,8 @@ template class LocatePlugin final : public BasePlugin int HandleRequest(const RouteParameters &route_parameters, JSON::Object &json_result) final { // check number of parameters - if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().is_valid()) + if (route_parameters.coordinates.empty() || + !route_parameters.coordinates.front().is_valid()) { return 400; } @@ -74,4 +75,4 @@ template class LocatePlugin final : public BasePlugin DataFacadeT *facade; }; -#endif /* LOCATE_PLUGIN_H */ +#endif /* LOCATE_HPP */ diff --git a/plugins/nearest.hpp b/plugins/nearest.hpp index 33bed1333..9add3040b 100644 --- a/plugins/nearest.hpp +++ b/plugins/nearest.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -25,14 +25,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef NEAREST_PLUGIN_H -#define NEAREST_PLUGIN_H +#ifndef NEAREST_HPP +#define NEAREST_HPP #include "plugin_base.hpp" #include "../data_structures/phantom_node.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/json_renderer.hpp" +#include "../util/integer_range.hpp" +#include "../util/json_renderer.hpp" #include @@ -52,7 +52,8 @@ template class NearestPlugin final : public BasePlugin int HandleRequest(const RouteParameters &route_parameters, JSON::Object &json_result) final { // check number of parameters - if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().is_valid()) + if (route_parameters.coordinates.empty() || + !route_parameters.coordinates.front().is_valid()) { return 400; } @@ -76,7 +77,8 @@ template class NearestPlugin final : public BasePlugin JSON::Array results; auto vector_length = phantom_node_vector.size(); - for (const auto i : osrm::irange(0, std::min(number_of_results, vector_length))) + for (const auto i : + osrm::irange(0, std::min(number_of_results, vector_length))) { JSON::Array json_coordinate; JSON::Object result; @@ -113,4 +115,4 @@ template class NearestPlugin final : public BasePlugin std::string descriptor_string; }; -#endif /* NEAREST_PLUGIN_H */ +#endif /* NEAREST_HPP */ diff --git a/plugins/timestamp.hpp b/plugins/timestamp.hpp index 181efbf7b..b86174a50 100644 --- a/plugins/timestamp.hpp +++ b/plugins/timestamp.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "plugin_base.hpp" -#include "../Util/json_renderer.hpp" +#include "../util/json_renderer.hpp" #include diff --git a/plugins/viaroute.hpp b/plugins/viaroute.hpp index bf6891163..b253baa1c 100644 --- a/plugins/viaroute.hpp +++ b/plugins/viaroute.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -35,10 +35,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../descriptors/descriptor_base.hpp" #include "../descriptors/gpx_descriptor.hpp" #include "../descriptors/json_descriptor.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/json_renderer.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/integer_range.hpp" +#include "../util/json_renderer.hpp" +#include "../util/make_unique.hpp" +#include "../util/simple_logger.hpp" #include diff --git a/routed.cpp b/routed.cpp index 78f48cc82..a5ba4906d 100644 --- a/routed.cpp +++ b/routed.cpp @@ -27,9 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "library/osrm.hpp" #include "server/server.hpp" -#include "Util/git_sha.hpp" -#include "Util/routed_options.hpp" -#include "Util/simple_logger.hpp" +#include "util/git_sha.hpp" +#include "util/routed_options.hpp" +#include "util/simple_logger.hpp" #ifdef __linux__ #include diff --git a/routing_algorithms/alternative_path.hpp b/routing_algorithms/alternative_path.hpp index ae1f62338..e3a81251b 100644 --- a/routing_algorithms/alternative_path.hpp +++ b/routing_algorithms/alternative_path.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -30,8 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "routing_base.hpp" #include "../data_structures/search_engine_data.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/container.hpp" +#include "../util/integer_range.hpp" +#include "../util/container.hpp" #include @@ -44,7 +44,8 @@ const double VIAPATH_ALPHA = 0.10; const double VIAPATH_EPSILON = 0.15; // alternative at most 15% longer const double VIAPATH_GAMMA = 0.75; // alternative shares at most 75% with the shortest. -template class AlternativeRouting final : private BasicRoutingInterface +template +class AlternativeRouting final : private BasicRoutingInterface { using super = BasicRoutingInterface; using EdgeData = typename DataFacadeT::EdgeData; @@ -148,22 +149,16 @@ template class AlternativeRouting final : private BasicRouti { if (0 < forward_heap1.Size()) { - AlternativeRoutingStep(forward_heap1, - reverse_heap1, - &middle_node, + AlternativeRoutingStep(forward_heap1, reverse_heap1, &middle_node, &upper_bound_to_shortest_path_distance, - via_node_candidate_list, - forward_search_space, + via_node_candidate_list, forward_search_space, min_edge_offset); } if (0 < reverse_heap1.Size()) { - AlternativeRoutingStep(reverse_heap1, - forward_heap1, - &middle_node, + AlternativeRoutingStep(reverse_heap1, forward_heap1, &middle_node, &upper_bound_to_shortest_path_distance, - via_node_candidate_list, - reverse_search_space, + via_node_candidate_list, reverse_search_space, min_edge_offset); } } @@ -274,19 +269,16 @@ template class AlternativeRouting final : private BasicRouti std::vector &packed_shortest_path = packed_forward_path; std::reverse(packed_shortest_path.begin(), packed_shortest_path.end()); packed_shortest_path.emplace_back(middle_node); - packed_shortest_path.insert( - packed_shortest_path.end(), packed_reverse_path.begin(), packed_reverse_path.end()); + packed_shortest_path.insert(packed_shortest_path.end(), packed_reverse_path.begin(), + packed_reverse_path.end()); std::vector ranked_candidates_list; // prioritizing via nodes for deep inspection for (const NodeID node : preselected_node_list) { int length_of_via_path = 0, sharing_of_via_path = 0; - ComputeLengthAndSharingOfViaPath(node, - &length_of_via_path, - &sharing_of_via_path, - packed_shortest_path, - min_edge_offset); + ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path, + packed_shortest_path, min_edge_offset); const int maximum_allowed_sharing = static_cast(upper_bound_to_shortest_path_distance * VIAPATH_GAMMA); if (sharing_of_via_path <= maximum_allowed_sharing && @@ -302,16 +294,10 @@ template class AlternativeRouting final : private BasicRouti NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID; for (const RankedCandidateNode &candidate : ranked_candidates_list) { - if (ViaNodeCandidatePassesTTest(forward_heap1, - reverse_heap1, - forward_heap2, - reverse_heap2, - candidate, - upper_bound_to_shortest_path_distance, - &length_of_via_path, - &s_v_middle, - &v_t_middle, - min_edge_offset)) + if (ViaNodeCandidatePassesTTest( + forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, candidate, + upper_bound_to_shortest_path_distance, &length_of_via_path, &s_v_middle, + &v_t_middle, min_edge_offset)) { // select first admissable selected_via_node = candidate.node; @@ -343,13 +329,8 @@ template class AlternativeRouting final : private BasicRouti { std::vector packed_alternate_path; // retrieve alternate path - RetrievePackedAlternatePath(forward_heap1, - reverse_heap1, - forward_heap2, - reverse_heap2, - s_v_middle, - v_t_middle, - packed_alternate_path); + RetrievePackedAlternatePath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, + s_v_middle, v_t_middle, packed_alternate_path); raw_route_data.alt_source_traversed_in_reverse.push_back(( packed_alternate_path.front() != phantom_node_pair.source_phantom.forward_node_id)); @@ -357,8 +338,8 @@ template class AlternativeRouting final : private BasicRouti (packed_alternate_path.back() != phantom_node_pair.target_phantom.forward_node_id)); // unpack the alternate path - super::UnpackPath( - packed_alternate_path, phantom_node_pair, raw_route_data.unpacked_alternative); + super::UnpackPath(packed_alternate_path, phantom_node_pair, + raw_route_data.unpacked_alternative); raw_route_data.alternative_path_length = length_of_via_path; } @@ -384,8 +365,8 @@ template class AlternativeRouting final : private BasicRouti packed_path.pop_back(); // remove middle node. It's in both half-paths // fetch patched path [v,t] - super::RetrievePackedPathFromHeap( - forward_heap2, reverse_heap1, v_t_middle, packed_v_t_path); + super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap1, v_t_middle, + packed_v_t_path); packed_path.insert(packed_path.end(), packed_v_t_path.begin(), packed_v_t_path.end()); } @@ -420,12 +401,8 @@ template class AlternativeRouting final : private BasicRouti // compute path by reusing forward search from s while (!new_reverse_heap.Empty()) { - super::RoutingStep(new_reverse_heap, - existing_forward_heap, - &s_v_middle, - &upper_bound_s_v_path_length, - min_edge_offset, - false); + super::RoutingStep(new_reverse_heap, existing_forward_heap, &s_v_middle, + &upper_bound_s_v_path_length, min_edge_offset, false); } // compute path by reusing backward search from node t NodeID v_t_middle = SPECIAL_NODEID; @@ -433,12 +410,8 @@ template class AlternativeRouting final : private BasicRouti new_forward_heap.Insert(via_node, 0, via_node); while (!new_forward_heap.Empty()) { - super::RoutingStep(new_forward_heap, - existing_reverse_heap, - &v_t_middle, - &upper_bound_of_v_t_path_length, - min_edge_offset, - true); + super::RoutingStep(new_forward_heap, existing_reverse_heap, &v_t_middle, + &upper_bound_of_v_t_path_length, min_edge_offset, true); } *real_length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length; @@ -448,10 +421,10 @@ template class AlternativeRouting final : private BasicRouti } // retrieve packed paths - super::RetrievePackedPathFromHeap( - existing_forward_heap, new_reverse_heap, s_v_middle, packed_s_v_path); - super::RetrievePackedPathFromHeap( - new_forward_heap, existing_reverse_heap, v_t_middle, packed_v_t_path); + super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, s_v_middle, + packed_s_v_path); + super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, v_t_middle, + packed_v_t_path); // partial unpacking, compute sharing // First partially unpack s-->v until paths deviate, note length of common path. @@ -484,12 +457,11 @@ template class AlternativeRouting final : private BasicRouti const int64_t packed_path_length = std::min(partially_unpacked_via_path.size(), partially_unpacked_shortest_path.size()) - 1; - for (int64_t current_node = 0; - (current_node < packed_path_length) && - (partially_unpacked_via_path[current_node] == - partially_unpacked_shortest_path[current_node] && - partially_unpacked_via_path[current_node + 1] == - partially_unpacked_shortest_path[current_node + 1]); + for (int64_t current_node = 0; (current_node < packed_path_length) && + (partially_unpacked_via_path[current_node] == + partially_unpacked_shortest_path[current_node] && + partially_unpacked_via_path[current_node + 1] == + partially_unpacked_shortest_path[current_node + 1]); ++current_node) { EdgeID selected_edge = @@ -517,8 +489,7 @@ template class AlternativeRouting final : private BasicRouti if (packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index]) { super::UnpackEdge(packed_v_t_path[via_path_index - 1], - packed_v_t_path[via_path_index], - partially_unpacked_via_path); + packed_v_t_path[via_path_index], partially_unpacked_via_path); super::UnpackEdge(packed_shortest_path[shortest_path_index - 1], packed_shortest_path[shortest_path_index], partially_unpacked_shortest_path); @@ -696,12 +667,8 @@ template class AlternativeRouting final : private BasicRouti new_reverse_heap.Insert(candidate.node, 0, candidate.node); while (new_reverse_heap.Size() > 0) { - super::RoutingStep(new_reverse_heap, - existing_forward_heap, - s_v_middle, - &upper_bound_s_v_path_length, - min_edge_offset, - false); + super::RoutingStep(new_reverse_heap, existing_forward_heap, s_v_middle, + &upper_bound_s_v_path_length, min_edge_offset, false); } if (INVALID_EDGE_WEIGHT == upper_bound_s_v_path_length) @@ -715,12 +682,8 @@ template class AlternativeRouting final : private BasicRouti new_forward_heap.Insert(candidate.node, 0, candidate.node); while (new_forward_heap.Size() > 0) { - super::RoutingStep(new_forward_heap, - existing_reverse_heap, - v_t_middle, - &upper_bound_of_v_t_path_length, - min_edge_offset, - true); + super::RoutingStep(new_forward_heap, existing_reverse_heap, v_t_middle, + &upper_bound_of_v_t_path_length, min_edge_offset, true); } if (INVALID_EDGE_WEIGHT == upper_bound_of_v_t_path_length) @@ -731,11 +694,11 @@ template class AlternativeRouting final : private BasicRouti *length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length; // retrieve packed paths - super::RetrievePackedPathFromHeap( - existing_forward_heap, new_reverse_heap, *s_v_middle, packed_s_v_path); + super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, *s_v_middle, + packed_s_v_path); - super::RetrievePackedPathFromHeap( - new_forward_heap, existing_reverse_heap, *v_t_middle, packed_v_t_path); + super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, *v_t_middle, + packed_v_t_path); NodeID s_P = *s_v_middle, t_P = *v_t_middle; if (SPECIAL_NODEID == s_P) @@ -815,8 +778,7 @@ template class AlternativeRouting final : private BasicRouti // Traverse path s-->v BOOST_ASSERT(!packed_v_t_path.empty()); for (unsigned i = 0, packed_path_length = static_cast(packed_v_t_path.size() - 1); - (i < packed_path_length) && unpack_stack.empty(); - ++i) + (i < packed_path_length) && unpack_stack.empty(); ++i) { const EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]); @@ -888,13 +850,13 @@ template class AlternativeRouting final : private BasicRouti { if (!forward_heap3.Empty()) { - super::RoutingStep( - forward_heap3, reverse_heap3, &middle, &upper_bound, min_edge_offset, true); + super::RoutingStep(forward_heap3, reverse_heap3, &middle, &upper_bound, + min_edge_offset, true); } if (!reverse_heap3.Empty()) { - super::RoutingStep( - reverse_heap3, forward_heap3, &middle, &upper_bound, min_edge_offset, false); + super::RoutingStep(reverse_heap3, forward_heap3, &middle, &upper_bound, + min_edge_offset, false); } } return (upper_bound <= t_test_path_length); diff --git a/routing_algorithms/routing_base.hpp b/routing_algorithms/routing_base.hpp index a120d9717..67dd2f5a8 100644 --- a/routing_algorithms/routing_base.hpp +++ b/routing_algorithms/routing_base.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/internal_route_result.hpp" #include "../data_structures/search_engine_data.hpp" #include "../data_structures/turn_instructions.hpp" -// #include "../Util/simple_logger.hpp" +// #include "../util/simple_logger.hpp" #include @@ -56,7 +56,7 @@ template class BasicRoutingInterface BasicRoutingInterface() = delete; BasicRoutingInterface(const BasicRoutingInterface &) = delete; explicit BasicRoutingInterface(DataFacadeT *facade) : facade(facade) {} - virtual ~BasicRoutingInterface() {}; + virtual ~BasicRoutingInterface(){}; inline void RoutingStep(SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &reverse_heap, @@ -69,7 +69,8 @@ template class BasicRoutingInterface const int distance = forward_heap.GetKey(node); // const NodeID parentnode = forward_heap.GetData(node).parent; - // SimpleLogger().Write() << (forward_direction ? "[fwd] " : "[rev] ") << "settled edge (" << parentnode << "," << node << "), dist: " << distance; + // SimpleLogger().Write() << (forward_direction ? "[fwd] " : "[rev] ") << "settled edge (" + // << parentnode << "," << node << "), dist: " << distance; if (reverse_heap.WasInserted(node)) { @@ -80,9 +81,11 @@ template class BasicRoutingInterface { *middle_node_id = node; *upper_bound = new_distance; - // SimpleLogger().Write() << "accepted middle node " << node << " at distance " << new_distance; - // } else { - // SimpleLogger().Write() << "discared middle node " << node << " at distance " << new_distance; + // SimpleLogger().Write() << "accepted middle node " << node << " at + // distance " << new_distance; + // } else { + // SimpleLogger().Write() << "discared middle node " << node << " at + // distance " << new_distance; } } } @@ -228,15 +231,11 @@ template class BasicRoutingInterface const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id); const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id); - if (!facade->EdgeIsCompressed(ed.id)) { BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id)); - unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id), - name_index, - turn_instruction, - ed.distance, - travel_mode); + unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id), name_index, + turn_instruction, ed.distance, travel_mode); } else { @@ -257,7 +256,8 @@ template class BasicRoutingInterface BOOST_ASSERT(start_index <= end_index); for (std::size_t i = start_index; i < end_index; ++i) { - unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0, travel_mode); + unpacked_path.emplace_back(id_vector[i], name_index, + TurnInstruction::NoTurn, 0, travel_mode); } unpacked_path.back().turn_instruction = turn_instruction; unpacked_path.back().segment_duration = ed.distance; @@ -294,18 +294,19 @@ template class BasicRoutingInterface if (start_index > end_index) { - start_index = std::min(start_index, id_vector.size()-1); + start_index = std::min(start_index, id_vector.size() - 1); } for (std::size_t i = start_index; i != end_index; (start_index < end_index ? ++i : --i)) { BOOST_ASSERT(i < id_vector.size()); - BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode>0 ); - unpacked_path.emplace_back(PathData{id_vector[i], - phantom_node_pair.target_phantom.name_id, - TurnInstruction::NoTurn, - 0, - phantom_node_pair.target_phantom.forward_travel_mode}); + BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0); + unpacked_path.emplace_back( + PathData{id_vector[i], + phantom_node_pair.target_phantom.name_id, + TurnInstruction::NoTurn, + 0, + phantom_node_pair.target_phantom.forward_travel_mode}); } } @@ -367,7 +368,8 @@ template class BasicRoutingInterface } } } - BOOST_ASSERT_MSG(edge_weight != std::numeric_limits::max(), "edge weight invalid"); + BOOST_ASSERT_MSG(edge_weight != std::numeric_limits::max(), + "edge weight invalid"); const EdgeData &ed = facade->GetEdgeData(smaller_edge_id); if (ed.shortcut) diff --git a/routing_algorithms/shortest_path.hpp b/routing_algorithms/shortest_path.hpp index f09d2cff6..8282aa25f 100644 --- a/routing_algorithms/shortest_path.hpp +++ b/routing_algorithms/shortest_path.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -32,10 +32,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "routing_base.hpp" #include "../data_structures/search_engine_data.hpp" -#include "../Util/integer_range.hpp" +#include "../util/integer_range.hpp" #include "../typedefs.h" -template class ShortestPathRouting final : public BasicRoutingInterface +template +class ShortestPathRouting final : public BasicRoutingInterface { using super = BasicRoutingInterface; using QueryHeap = SearchEngineData::QueryHeap; @@ -88,7 +89,8 @@ template class ShortestPathRouting final : public BasicRouti middle1 = SPECIAL_NODEID; middle2 = SPECIAL_NODEID; - const bool allow_u_turn = current_leg > 0 && uturn_indicators.size() > current_leg && uturn_indicators[current_leg-1]; + const bool allow_u_turn = current_leg > 0 && uturn_indicators.size() > current_leg && + uturn_indicators[current_leg - 1]; EdgeWeight min_edge_offset = 0; // insert new starting nodes into forward heap, adjusted by previous distances. @@ -97,35 +99,58 @@ template class ShortestPathRouting final : public BasicRouti { forward_heap1.Insert( phantom_node_pair.source_phantom.forward_node_id, - (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(), + (allow_u_turn ? 0 : distance1) - + phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(), phantom_node_pair.source_phantom.forward_node_id); - min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset()); - // SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(); + min_edge_offset = + std::min(min_edge_offset, + (allow_u_turn ? 0 : distance1) - + phantom_node_pair.source_phantom.GetForwardWeightPlusOffset()); + // SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " << + // phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0 + // : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(); forward_heap2.Insert( phantom_node_pair.source_phantom.forward_node_id, - (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(), + (allow_u_turn ? 0 : distance1) - + phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(), phantom_node_pair.source_phantom.forward_node_id); - min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset()); - // SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(); - + min_edge_offset = + std::min(min_edge_offset, + (allow_u_turn ? 0 : distance1) - + phantom_node_pair.source_phantom.GetForwardWeightPlusOffset()); + // SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " << + // phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0 + // : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(); } if ((allow_u_turn || search_from_2nd_node) && phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID) { forward_heap1.Insert( phantom_node_pair.source_phantom.reverse_node_id, - (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(), + (allow_u_turn ? 0 : distance2) - + phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(), phantom_node_pair.source_phantom.reverse_node_id); - min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset()); - // SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " << phantom_node_pair.source_phantom.reverse_node_id << - // ", w: " << (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(); + min_edge_offset = + std::min(min_edge_offset, + (allow_u_turn ? 0 : distance2) - + phantom_node_pair.source_phantom.GetReverseWeightPlusOffset()); + // SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " << + // phantom_node_pair.source_phantom.reverse_node_id << + // ", w: " << (allow_u_turn ? 0 : distance2) - + // phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(); forward_heap2.Insert( phantom_node_pair.source_phantom.reverse_node_id, - (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(), + (allow_u_turn ? 0 : distance2) - + phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(), phantom_node_pair.source_phantom.reverse_node_id); - min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset()); - // SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " << phantom_node_pair.source_phantom.reverse_node_id << - // ", w: " << (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(); + min_edge_offset = + std::min(min_edge_offset, + (allow_u_turn ? 0 : distance2) - + phantom_node_pair.source_phantom.GetReverseWeightPlusOffset()); + // SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " << + // phantom_node_pair.source_phantom.reverse_node_id << + // ", w: " << (allow_u_turn ? 0 : distance2) - + // phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(); } // insert new backward nodes into backward heap, unadjusted. @@ -134,17 +159,21 @@ template class ShortestPathRouting final : public BasicRouti reverse_heap1.Insert(phantom_node_pair.target_phantom.forward_node_id, phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(), phantom_node_pair.target_phantom.forward_node_id); - // SimpleLogger().Write(logDEBUG) << "rev-a insert: " << phantom_node_pair.target_phantom.forward_node_id << - // ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(); - } + // SimpleLogger().Write(logDEBUG) << "rev-a insert: " << + // phantom_node_pair.target_phantom.forward_node_id << + // ", w: " << + // phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(); + } if (phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID) { reverse_heap2.Insert(phantom_node_pair.target_phantom.reverse_node_id, phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(), phantom_node_pair.target_phantom.reverse_node_id); - // SimpleLogger().Write(logDEBUG) << "rev-a insert: " << phantom_node_pair.target_phantom.reverse_node_id << - // ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(); + // SimpleLogger().Write(logDEBUG) << "rev-a insert: " << + // phantom_node_pair.target_phantom.reverse_node_id << + // ", w: " << + // phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(); } // run two-Target Dijkstra routing step. @@ -152,13 +181,13 @@ template class ShortestPathRouting final : public BasicRouti { if (!forward_heap1.Empty()) { - super::RoutingStep( - forward_heap1, reverse_heap1, &middle1, &local_upper_bound1, min_edge_offset, true); + super::RoutingStep(forward_heap1, reverse_heap1, &middle1, &local_upper_bound1, + min_edge_offset, true); } if (!reverse_heap1.Empty()) { - super::RoutingStep( - reverse_heap1, forward_heap1, &middle1, &local_upper_bound1, min_edge_offset, false); + super::RoutingStep(reverse_heap1, forward_heap1, &middle1, &local_upper_bound1, + min_edge_offset, false); } } @@ -168,13 +197,13 @@ template class ShortestPathRouting final : public BasicRouti { if (!forward_heap2.Empty()) { - super::RoutingStep( - forward_heap2, reverse_heap2, &middle2, &local_upper_bound2, min_edge_offset, true); + super::RoutingStep(forward_heap2, reverse_heap2, &middle2, + &local_upper_bound2, min_edge_offset, true); } if (!reverse_heap2.Empty()) { - super::RoutingStep( - reverse_heap2, forward_heap2, &middle2, &local_upper_bound2, min_edge_offset, false); + super::RoutingStep(reverse_heap2, forward_heap2, &middle2, + &local_upper_bound2, min_edge_offset, false); } } } @@ -200,7 +229,8 @@ template class ShortestPathRouting final : public BasicRouti } // Was at most one of the two paths not found? - BOOST_ASSERT_MSG((INVALID_EDGE_WEIGHT != distance1 || INVALID_EDGE_WEIGHT != distance2), "no path found"); + BOOST_ASSERT_MSG((INVALID_EDGE_WEIGHT != distance1 || INVALID_EDGE_WEIGHT != distance2), + "no path found"); // Unpack paths if they exist std::vector temporary_packed_leg1; @@ -211,18 +241,19 @@ template class ShortestPathRouting final : public BasicRouti if (INVALID_EDGE_WEIGHT != local_upper_bound1) { - super::RetrievePackedPathFromHeap( - forward_heap1, reverse_heap1, middle1, temporary_packed_leg1); + super::RetrievePackedPathFromHeap(forward_heap1, reverse_heap1, middle1, + temporary_packed_leg1); } if (INVALID_EDGE_WEIGHT != local_upper_bound2) { - super::RetrievePackedPathFromHeap( - forward_heap2, reverse_heap2, middle2, temporary_packed_leg2); + super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap2, middle2, + temporary_packed_leg2); } // if one of the paths was not found, replace it with the other one. - if ((allow_u_turn && local_upper_bound1 > local_upper_bound2) || temporary_packed_leg1.empty()) + if ((allow_u_turn && local_upper_bound1 > local_upper_bound2) || + temporary_packed_leg1.empty()) { temporary_packed_leg1.clear(); temporary_packed_leg1.insert(temporary_packed_leg1.end(), @@ -230,7 +261,8 @@ template class ShortestPathRouting final : public BasicRouti temporary_packed_leg2.end()); local_upper_bound1 = local_upper_bound2; } - if ((allow_u_turn && local_upper_bound2 > local_upper_bound1) || temporary_packed_leg2.empty()) + if ((allow_u_turn && local_upper_bound2 > local_upper_bound1) || + temporary_packed_leg2.empty()) { temporary_packed_leg2.clear(); temporary_packed_leg2.insert(temporary_packed_leg2.end(), @@ -287,7 +319,8 @@ template class ShortestPathRouting final : public BasicRouti temporary_packed_leg2.end()); BOOST_ASSERT(packed_legs2[current_leg].size() == temporary_packed_leg2.size()); - if (!allow_u_turn && (packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) && + if (!allow_u_turn && + (packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) && phantom_node_pair.target_phantom.is_bidirected()) { const NodeID last_node_id = packed_legs2[current_leg].back(); @@ -324,9 +357,11 @@ template class ShortestPathRouting final : public BasicRouti raw_route_data.unpacked_path_segments[index]); raw_route_data.source_traversed_in_reverse.push_back( - (packed_legs1[index].front() != phantom_nodes_vector[index].source_phantom.forward_node_id)); + (packed_legs1[index].front() != + phantom_nodes_vector[index].source_phantom.forward_node_id)); raw_route_data.target_traversed_in_reverse.push_back( - (packed_legs1[index].back() != phantom_nodes_vector[index].target_phantom.forward_node_id)); + (packed_legs1[index].back() != + phantom_nodes_vector[index].target_phantom.forward_node_id)); } raw_route_data.shortest_path_length = std::min(distance1, distance2); } diff --git a/server/Http/Reply.cpp b/server/Http/Reply.cpp index 89b931b05..2642e2be2 100644 --- a/server/Http/Reply.cpp +++ b/server/Http/Reply.cpp @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "reply.hpp" -#include "../../Util/cast.hpp" +#include "../../util/cast.hpp" namespace http { diff --git a/server/data_structures/datafacade_base.hpp b/server/data_structures/datafacade_base.hpp index 2de79f915..0dbeef4b6 100644 --- a/server/data_structures/datafacade_base.hpp +++ b/server/data_structures/datafacade_base.hpp @@ -34,9 +34,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/external_memory_node.hpp" #include "../../data_structures/phantom_node.hpp" #include "../../data_structures/turn_instructions.hpp" -#include "../../Util/integer_range.hpp" -#include "../../Util/osrm_exception.hpp" -#include "../../Util/string_util.hpp" +#include "../../util/integer_range.hpp" +#include "../../util/osrm_exception.hpp" +#include "../../util/string_util.hpp" #include "../../typedefs.h" #include diff --git a/server/data_structures/internal_datafacade.hpp b/server/data_structures/internal_datafacade.hpp index f25185a1e..8a481c5c5 100644 --- a/server/data_structures/internal_datafacade.hpp +++ b/server/data_structures/internal_datafacade.hpp @@ -39,9 +39,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/static_graph.hpp" #include "../../data_structures/static_rtree.hpp" #include "../../data_structures/range_table.hpp" -#include "../../Util/boost_filesystem_2_fix.hpp" -#include "../../Util/graph_loader.hpp" -#include "../../Util/simple_logger.hpp" +#include "../../util/boost_filesystem_2_fix.hpp" +#include "../../util/graph_loader.hpp" +#include "../../util/simple_logger.hpp" #include #include diff --git a/server/data_structures/shared_datafacade.hpp b/server/data_structures/shared_datafacade.hpp index 1b038dc89..b6a144174 100644 --- a/server/data_structures/shared_datafacade.hpp +++ b/server/data_structures/shared_datafacade.hpp @@ -36,9 +36,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/range_table.hpp" #include "../../data_structures/static_graph.hpp" #include "../../data_structures/static_rtree.hpp" -#include "../../Util/boost_filesystem_2_fix.hpp" -#include "../../Util/make_unique.hpp" -#include "../../Util/simple_logger.hpp" +#include "../../util/boost_filesystem_2_fix.hpp" +#include "../../util/make_unique.hpp" +#include "../../util/simple_logger.hpp" #include #include diff --git a/server/data_structures/shared_datatype.hpp b/server/data_structures/shared_datatype.hpp index 9464ff015..0c0b23910 100644 --- a/server/data_structures/shared_datatype.hpp +++ b/server/data_structures/shared_datatype.hpp @@ -28,8 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SHARED_DATA_TYPE_HPP #define SHARED_DATA_TYPE_HPP -#include "../../Util/osrm_exception.hpp" -#include "../../Util/simple_logger.hpp" +#include "../../util/osrm_exception.hpp" +#include "../../util/simple_logger.hpp" #include diff --git a/server/http/reply.cpp b/server/http/reply.cpp index 89b931b05..2642e2be2 100644 --- a/server/http/reply.cpp +++ b/server/http/reply.cpp @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "reply.hpp" -#include "../../Util/cast.hpp" +#include "../../util/cast.hpp" namespace http { diff --git a/server/request_handler.cpp b/server/request_handler.cpp index 17a004338..464ba5b94 100644 --- a/server/request_handler.cpp +++ b/server/request_handler.cpp @@ -32,10 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "http/request.hpp" #include "../library/osrm.hpp" -#include "../Util/json_renderer.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/string_util.hpp" -#include "../Util/xml_renderer.hpp" +#include "../util/json_renderer.hpp" +#include "../util/simple_logger.hpp" +#include "../util/string_util.hpp" +#include "../util/xml_renderer.hpp" #include "../typedefs.h" #include diff --git a/server/server.hpp b/server/server.hpp index ee9887e52..46a87d23a 100644 --- a/server/server.hpp +++ b/server/server.hpp @@ -31,9 +31,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "connection.hpp" #include "request_handler.hpp" -#include "../Util/cast.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/cast.hpp" +#include "../util/integer_range.hpp" +#include "../util/simple_logger.hpp" #include #include diff --git a/tools/check-hsgr.cpp b/tools/check-hsgr.cpp index 9173dc4f7..be2f973c7 100644 --- a/tools/check-hsgr.cpp +++ b/tools/check-hsgr.cpp @@ -27,10 +27,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/percent.hpp" #include "../data_structures/query_edge.hpp" #include "../data_structures/static_graph.hpp" -#include "../Util/integer_range.hpp" -#include "../Util/graph_loader.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/osrm_exception.hpp" +#include "../util/integer_range.hpp" +#include "../util/graph_loader.hpp" +#include "../util/simple_logger.hpp" +#include "../util/osrm_exception.hpp" #include #include @@ -86,17 +86,17 @@ int main(int argc, char *argv[]) if (SPECIAL_EDGEID == edge_id_1) { throw osrm::exception("cannot find first segment of edge (" + - std::to_string(node_u) + "," + std::to_string(data.id) + - "," + std::to_string(node_v) + "), eid: " + - std::to_string(eid)); + std::to_string(node_u) + "," + std::to_string(data.id) + + "," + std::to_string(node_v) + "), eid: " + + std::to_string(eid)); } const EdgeID edge_id_2 = m_query_graph->FindEdgeInEitherDirection(data.id, node_v); if (SPECIAL_EDGEID == edge_id_2) { throw osrm::exception("cannot find second segment of edge (" + - std::to_string(node_u) + "," + std::to_string(data.id) + - "," + std::to_string(node_v) + "), eid: " + - std::to_string(eid)); + std::to_string(node_u) + "," + std::to_string(data.id) + + "," + std::to_string(node_v) + "), eid: " + + std::to_string(eid)); } } progress.printStatus(node_u); diff --git a/tools/components.cpp b/tools/components.cpp index f7308d724..733c8ff84 100644 --- a/tools/components.cpp +++ b/tools/components.cpp @@ -29,15 +29,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../algorithms/tiny_components.hpp" #include "../data_structures/static_graph.hpp" #include "../data_structures/coordinate_calculation.hpp" -#include "../Util/fingerprint.hpp" -#include "../Util/graph_loader.hpp" -#include "../Util/make_unique.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/fingerprint.hpp" +#include "../util/graph_loader.hpp" +#include "../util/make_unique.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" #include -#if defined(__APPLE__) || defined (_WIN32) +#if defined(__APPLE__) || defined(_WIN32) #include #include #else @@ -52,7 +52,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace { +namespace +{ struct TarjanEdgeData { @@ -129,15 +130,11 @@ int main(int argc, char *argv[]) // load graph data std::vector edge_list; - const NodeID number_of_nodes = readBinaryOSRMGraphFromStream(input_stream, - edge_list, - bollard_node_list, - traffic_lights_list, - &coordinate_list, - restriction_list); + const NodeID number_of_nodes = + readBinaryOSRMGraphFromStream(input_stream, edge_list, bollard_node_list, + traffic_lights_list, &coordinate_list, restriction_list); input_stream.close(); - BOOST_ASSERT_MSG(restriction_list.size() == usable_restrictions, "size of restriction_list changed"); @@ -159,17 +156,15 @@ int main(int argc, char *argv[]) if (input_edge.forward) { - graph_edge_list.emplace_back(input_edge.source, - input_edge.target, - (std::max)((int)input_edge.weight, 1), - input_edge.name_id); + graph_edge_list.emplace_back(input_edge.source, input_edge.target, + (std::max)((int)input_edge.weight, 1), + input_edge.name_id); } if (input_edge.backward) { - graph_edge_list.emplace_back(input_edge.target, - input_edge.source, - (std::max)((int)input_edge.weight, 1), - input_edge.name_id); + graph_edge_list.emplace_back(input_edge.target, input_edge.source, + (std::max)((int)input_edge.weight, 1), + input_edge.name_id); } } edge_list.clear(); @@ -185,12 +180,11 @@ int main(int argc, char *argv[]) SimpleLogger().Write() << "Starting SCC graph traversal"; RestrictionMap restriction_map(restriction_list); - auto tarjan = osrm::make_unique>(graph, - restriction_map, - bollard_node_list); + auto tarjan = + osrm::make_unique>(graph, restriction_map, bollard_node_list); tarjan->run(); SimpleLogger().Write() << "identified: " << tarjan->get_number_of_components() - << " many components"; + << " many components"; SimpleLogger().Write() << "identified " << tarjan->get_size_one_count() << " size 1 SCCs"; // output @@ -229,7 +223,8 @@ int main(int argc, char *argv[]) throw osrm::exception("Layer creation failed."); } TIMER_STOP(SCC_RUN_SETUP); - SimpleLogger().Write() << "shapefile setup took " << TIMER_MSEC(SCC_RUN_SETUP)/1000. << "s"; + SimpleLogger().Write() << "shapefile setup took " << TIMER_MSEC(SCC_RUN_SETUP) / 1000. + << "s"; uint64_t total_network_distance = 0; p.reinit(graph->GetNumberOfNodes()); @@ -245,18 +240,15 @@ int main(int argc, char *argv[]) { total_network_distance += 100 * coordinate_calculation::euclidean_distance( - coordinate_list[source].lat, - coordinate_list[source].lon, - coordinate_list[target].lat, - coordinate_list[target].lon); + coordinate_list[source].lat, coordinate_list[source].lon, + coordinate_list[target].lat, coordinate_list[target].lon); BOOST_ASSERT(current_edge != SPECIAL_EDGEID); BOOST_ASSERT(source != SPECIAL_NODEID); BOOST_ASSERT(target != SPECIAL_NODEID); - const unsigned size_of_containing_component = - std::min(tarjan->get_component_size(source), - tarjan->get_component_size(target)); + const unsigned size_of_containing_component = std::min( + tarjan->get_component_size(source), tarjan->get_component_size(target)); // edges that end on bollard nodes may actually be in two distinct components if (size_of_containing_component < 1000) @@ -282,7 +274,8 @@ int main(int argc, char *argv[]) OGRSpatialReference::DestroySpatialReference(poSRS); OGRDataSource::DestroyDataSource(poDS); TIMER_STOP(SCC_OUTPUT); - SimpleLogger().Write() << "generating output took: " << TIMER_MSEC(SCC_OUTPUT)/1000. << "s"; + SimpleLogger().Write() << "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000. + << "s"; SimpleLogger().Write() << "total network distance: " << (uint64_t)total_network_distance / 100 / 1000. << " km"; diff --git a/tools/io-benchmark.cpp b/tools/io-benchmark.cpp index c6da3ad44..277bd2ad1 100644 --- a/tools/io-benchmark.cpp +++ b/tools/io-benchmark.cpp @@ -25,10 +25,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../Util/git_sha.hpp" -#include "../Util/osrm_exception.hpp" -#include "../Util/simple_logger.hpp" -#include "../Util/timing_util.hpp" +#include "../util/git_sha.hpp" +#include "../util/osrm_exception.hpp" +#include "../util/simple_logger.hpp" +#include "../util/timing_util.hpp" #include #include @@ -63,8 +63,8 @@ void RunStatistics(std::vector &timings_vector, Statistics &stats) double primary_sum = std::accumulate(timings_vector.begin(), timings_vector.end(), 0.0); stats.mean = primary_sum / timings_vector.size(); - double primary_sq_sum = std::inner_product( - timings_vector.begin(), timings_vector.end(), timings_vector.begin(), 0.0); + double primary_sq_sum = std::inner_product(timings_vector.begin(), timings_vector.end(), + timings_vector.begin(), 0.0); stats.dev = std::sqrt(primary_sq_sum / timings_vector.size() - (stats.mean * stats.mean)); } @@ -72,12 +72,12 @@ int main(int argc, char *argv[]) { #ifdef __FreeBSD__ - SimpleLogger().Write() << "Not supported on FreeBSD"; - return 0; + SimpleLogger().Write() << "Not supported on FreeBSD"; + return 0; #endif #ifdef _WIN32 - SimpleLogger().Write() << "Not supported on Windows"; - return 0; + SimpleLogger().Write() << "Not supported on Windows"; + return 0; #else LogPolicy::GetInstance().Unmute(); @@ -206,7 +206,7 @@ int main(int argc, char *argv[]) std::uniform_int_distribution uniform_dist(0, number_of_blocks - 1); for (unsigned i = 0; i < 1000; ++i) { - unsigned block_to_read =uniform_dist(e1); + unsigned block_to_read = uniform_dist(e1); off_t current_offset = block_to_read * 4096; TIMER_START(random_access); #ifdef __APPLE__ diff --git a/tools/simpleclient.cpp b/tools/simpleclient.cpp index 8de120821..2567b9319 100644 --- a/tools/simpleclient.cpp +++ b/tools/simpleclient.cpp @@ -26,10 +26,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "../library/osrm.hpp" -#include "../Util/git_sha.hpp" -#include "../Util/json_renderer.hpp" -#include "../Util/routed_options.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/git_sha.hpp" +#include "../util/json_renderer.hpp" +#include "../util/routed_options.hpp" +#include "../util/simple_logger.hpp" #include #include diff --git a/tools/springclean.cpp b/tools/springclean.cpp index 054133a58..cb4559c1c 100644 --- a/tools/springclean.cpp +++ b/tools/springclean.cpp @@ -29,8 +29,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../data_structures/shared_memory_factory.hpp" #include "../server/data_structures/shared_datatype.hpp" -#include "../Util/git_sha.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/git_sha.hpp" +#include "../util/simple_logger.hpp" void delete_region(const SharedDataType region) { diff --git a/tools/unlock_all_mutexes.cpp b/tools/unlock_all_mutexes.cpp index f68ec32a7..9a279ee1e 100644 --- a/tools/unlock_all_mutexes.cpp +++ b/tools/unlock_all_mutexes.cpp @@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../Util/git_sha.hpp" -#include "../Util/simple_logger.hpp" +#include "../util/git_sha.hpp" +#include "../util/simple_logger.hpp" #include "../server/data_structures/shared_barriers.hpp" #include diff --git a/unit_tests/data_structures/static_rtree.cpp b/unit_tests/data_structures/static_rtree.cpp index 1e2676b4e..44912a6f6 100644 --- a/unit_tests/data_structures/static_rtree.cpp +++ b/unit_tests/data_structures/static_rtree.cpp @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../data_structures/static_rtree.hpp" #include "../../data_structures/query_node.hpp" #include "../../data_structures/edge_based_node.hpp" -#include "../../Util/floating_point.hpp" +#include "../../util/floating_point.hpp" #include "../../typedefs.h" #include diff --git a/util/bearing.cpp b/util/bearing.cpp new file mode 100644 index 000000000..92c47e6b8 --- /dev/null +++ b/util/bearing.cpp @@ -0,0 +1,65 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "bearing.hpp" + +std::string bearing::get(const double heading) +{ + if (heading <= 22.5) + { + return "N"; + } + if (heading <= 67.5) + { + return "NE"; + } + if (heading <= 112.5) + { + return "E"; + } + if (heading <= 157.5) + { + return "SE"; + } + if (heading <= 202.5) + { + return "S"; + } + if (heading <= 247.5) + { + return "SW"; + } + if (heading <= 292.5) + { + return "W"; + } + if (heading <= 337.5) + { + return "NW"; + } + return "N"; +} diff --git a/util/bearing.hpp b/util/bearing.hpp new file mode 100644 index 000000000..0066e9e02 --- /dev/null +++ b/util/bearing.hpp @@ -0,0 +1,38 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef BEARING_HPP +#define BEARING_HPP + +#include + +struct bearing +{ + static std::string get(const double heading); +}; + +#endif // BEARING_HPP diff --git a/util/boost_filesystem_2_fix.hpp b/util/boost_filesystem_2_fix.hpp new file mode 100644 index 000000000..aeab380b2 --- /dev/null +++ b/util/boost_filesystem_2_fix.hpp @@ -0,0 +1,144 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef BOOST_FILE_SYSTEM_FIX_H +#define BOOST_FILE_SYSTEM_FIX_H + +#include "osrm_exception.hpp" + +// #include +#include +// #include + +// This is one big workaround for latest boost renaming woes. + +#if BOOST_FILESYSTEM_VERSION < 3 +#warning Boost Installation with Filesystem3 missing, activating workaround +#include +#endif + +namespace boost +{ +namespace filesystem +{ + +// Validator for boost::filesystem::path, that verifies that the file +// exists. The validate() function must be defined in the same namespace +// as the target type, (boost::filesystem::path in this case), otherwise +// it is not called +// inline void validate( +// boost::any & v, +// const std::vector & values, +// boost::filesystem::path *, +// int +// ) { +// boost::program_options::validators::check_first_occurrence(v); +// const std::string & input_string = +// boost::program_options::validators::get_single_string(values); +// if(boost::filesystem::is_regular_file(input_string)) { +// v = boost::any(boost::filesystem::path(input_string)); +// } else { +// throw osrm::exception(input_string + " not found"); +// } +// } + +// adapted from: +// http://stackoverflow.com/questions/1746136/how-do-i-normalize-a-pathname-using-boostfilesystem +inline boost::filesystem::path +portable_canonical(const boost::filesystem::path &relative_path, + const boost::filesystem::path ¤t_path = boost::filesystem::current_path()) +{ + const boost::filesystem::path absolute_path = + boost::filesystem::absolute(relative_path, current_path); + + boost::filesystem::path canonical_path; + for (auto path_iterator = absolute_path.begin(); path_iterator != absolute_path.end(); + ++path_iterator) + { + if (".." == path_iterator->string()) + { + // /a/b/.. is not necessarily /a if b is a symbolic link + if (boost::filesystem::is_symlink(canonical_path)) + { + canonical_path /= *path_iterator; + } + else if (".." == canonical_path.filename()) + { + // /a/b/../.. is not /a/b/.. under most circumstances + // We can end up with ..s in our result because of symbolic links + canonical_path /= *path_iterator; + } + else + { + // Otherwise it should be safe to resolve the parent + canonical_path = canonical_path.parent_path(); + } + } + else if ("." == path_iterator->string()) + { + // Ignore + } + else + { + // Just cat other path entries + canonical_path /= *path_iterator; + } + } + BOOST_ASSERT(canonical_path.is_absolute()); + BOOST_ASSERT(boost::filesystem::exists(canonical_path)); + return canonical_path; +} + +#if BOOST_FILESYSTEM_VERSION < 3 + +inline path temp_directory_path() +{ + char *buffer; + buffer = tmpnam(nullptr); + + return path(buffer); +} + +inline path unique_path(const path &) { return temp_directory_path(); } + +#endif +} +} + +#ifndef BOOST_FILESYSTEM_VERSION +#define BOOST_FILESYSTEM_VERSION 3 +#endif + +inline void AssertPathExists(const boost::filesystem::path &path) +{ + if (!boost::filesystem::is_regular_file(path)) + { + throw osrm::exception(path.string() + " not found."); + } +} + +#endif /* BOOST_FILE_SYSTEM_FIX_H */ diff --git a/util/cast.hpp b/util/cast.hpp new file mode 100644 index 000000000..e28b9ff84 --- /dev/null +++ b/util/cast.hpp @@ -0,0 +1,185 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef CAST_HPP +#define CAST_HPP + +#include +#include + +#include +#include + +struct cast +{ + // convert scoped enums to integers + template + static auto enum_to_underlying(Enumeration const value) -> + typename std::underlying_type::type + { + return static_cast::type>(value); + } + + template + static typename std::enable_if::value, std::string>::type + integral_to_string(const Number value) + { + std::string output; + std::back_insert_iterator sink(output); + + if (8 == sizeof(Number)) + { + boost::spirit::karma::generate(sink, boost::spirit::karma::long_long, value); + } + else + { + if (std::is_signed::value) + { + boost::spirit::karma::generate(sink, boost::spirit::karma::int_, value); + } + else + { + boost::spirit::karma::generate(sink, boost::spirit::karma::uint_, value); + } + } + return output; + } + + static int string_to_int(const std::string &input) + { + auto first_digit = input.begin(); + // Delete any trailing white-spaces + while (first_digit != input.end() && std::isspace(*first_digit)) + { + ++first_digit; + } + int value = 0; + boost::spirit::qi::parse(first_digit, input.end(), boost::spirit::int_, value); + return value; + } + + static unsigned string_to_uint(const std::string &input) + { + auto first_digit = input.begin(); + // Delete any trailing white-spaces + while (first_digit != input.end() && (std::isspace(*first_digit) || '-' == *first_digit)) + { + ++first_digit; + } + unsigned value = 0; + boost::spirit::qi::parse(first_digit, input.end(), boost::spirit::uint_, value); + return value; + } + + static uint64_t string_to_uint64(const std::string &input) + { + auto first_digit = input.begin(); + // Delete any trailing white-spaces + while (first_digit != input.end() && std::isspace(*first_digit)) + { + ++first_digit; + } + uint64_t value = 0; + boost::spirit::qi::parse(first_digit, input.end(), boost::spirit::long_long, value); + return value; + } + + // source: http://tinodidriksen.com/2011/05/28/cpp-convert-string-to-double-speed/ + static double string_to_double(const char *p) + { + double r = 0.0; + bool neg = false; + if (*p == '-') + { + neg = true; + ++p; + } + while (*p >= '0' && *p <= '9') + { + r = (r * 10.0) + (*p - '0'); + ++p; + } + if (*p == '.') + { + double f = 0.0; + int n = 0; + ++p; + while (*p >= '0' && *p <= '9') + { + f = (f * 10.0) + (*p - '0'); + ++p; + ++n; + } + r += f / std::pow(10.0, n); + } + if (neg) + { + r = -r; + } + return r; + } + + template struct scientific_policy : boost::spirit::karma::real_policies + { + // we want the numbers always to be in fixed format + static int floatfield(T) { return boost::spirit::karma::real_policies::fmtflags::fixed; } + static unsigned int precision(T) { return 6; } + }; + typedef boost::spirit::karma::real_generator> science_type; + + static std::string double_fixed_to_string(const double value) + { + std::string output; + std::back_insert_iterator sink(output); + boost::spirit::karma::generate(sink, science_type(), value); + if (output.size() >= 2 && output[output.size() - 2] == '.' && + output[output.size() - 1] == '0') + { + output.resize(output.size() - 2); + } + return output; + } + + static std::string double_to_string(const double value) + { + std::string output; + std::back_insert_iterator sink(output); + boost::spirit::karma::generate(sink, value); + return output; + } + + static void double_with_two_digits_to_string(const double value, std::string &output) + { + // The largest 32-bit integer is 4294967295, that is 10 chars + // On the safe side, add 1 for sign, and 1 for trailing zero + char buffer[12]; + sprintf(buffer, "%g", value); + output = buffer; + } +}; + +#endif // CAST_HPP diff --git a/util/compute_angle.cpp b/util/compute_angle.cpp new file mode 100644 index 000000000..e83b67b75 --- /dev/null +++ b/util/compute_angle.cpp @@ -0,0 +1,54 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "compute_angle.hpp" + +#include "trigonometry_table.hpp" +#include "../util/mercator.hpp" + +#include + +#include + +double ComputeAngle::OfThreeFixedPointCoordinates(const FixedPointCoordinate &first, + const FixedPointCoordinate &second, + const FixedPointCoordinate &third) +{ + const double v1x = (first.lon - second.lon) / COORDINATE_PRECISION; + const double v1y = mercator::lat2y(first.lat / COORDINATE_PRECISION) - + mercator::lat2y(second.lat / COORDINATE_PRECISION); + const double v2x = (third.lon - second.lon) / COORDINATE_PRECISION; + const double v2y = mercator::lat2y(third.lat / COORDINATE_PRECISION) - + mercator::lat2y(second.lat / COORDINATE_PRECISION); + + double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180. / M_PI; + while (angle < 0.) + { + angle += 360.; + } + return angle; +} diff --git a/util/compute_angle.hpp b/util/compute_angle.hpp new file mode 100644 index 000000000..73682bceb --- /dev/null +++ b/util/compute_angle.hpp @@ -0,0 +1,42 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef COMPUTE_ANGLE_HPP +#define COMPUTE_ANGLE_HPP + +struct FixedPointCoordinate; + +struct ComputeAngle +{ + // Get angle of line segment (A,C)->(C,B) + // atan2 magic, formerly cosine theorem + static double OfThreeFixedPointCoordinates(const FixedPointCoordinate &first, + const FixedPointCoordinate &second, + const FixedPointCoordinate &third); +}; + +#endif // COMPUTE_ANGLE_HPP diff --git a/util/container.hpp b/util/container.hpp new file mode 100644 index 000000000..a35d56a6d --- /dev/null +++ b/util/container.hpp @@ -0,0 +1,85 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef CONTAINER_HPP_ +#define CONTAINER_HPP_ + +#include +#include +#include + +namespace osrm +{ +template void sort_unique_resize(std::vector &vector) +{ + std::sort(vector.begin(), vector.end()); + const auto number_of_unique_elements = + std::unique(vector.begin(), vector.end()) - vector.begin(); + vector.resize(number_of_unique_elements); +} + +// template inline void sort_unique_resize_shrink_vector(std::vector &vector) +// { +// sort_unique_resize(vector); +// vector.shrink_to_fit(); +// } + +// template inline void remove_consecutive_duplicates_from_vector(std::vector +// &vector) +// { +// const auto number_of_unique_elements = std::unique(vector.begin(), vector.end()) - +// vector.begin(); +// vector.resize(number_of_unique_elements); +// } + +template +Function for_each_pair(ForwardIterator begin, ForwardIterator end, Function function) +{ + if (begin == end) + { + return function; + } + + auto next = begin; + next = std::next(next); + + while (next != end) + { + function(*begin, *next); + begin = std::next(begin); + next = std::next(next); + } + return function; +} + +template +Function for_each_pair(ContainerT &container, Function function) +{ + return for_each_pair(std::begin(container), std::end(container), function); +} +} +#endif /* CONTAINER_HPP_ */ diff --git a/util/datastore_options.hpp b/util/datastore_options.hpp new file mode 100644 index 000000000..1992860b5 --- /dev/null +++ b/util/datastore_options.hpp @@ -0,0 +1,273 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef DATASTORE_OPTIONS_HPP +#define DATASTORE_OPTIONS_HPP + +#include "boost_filesystem_2_fix.hpp" +#include "git_sha.hpp" +#include "ini_file.hpp" +#include "osrm_exception.hpp" +#include "simple_logger.hpp" + +#include + +#include +#include +#include + +#include + +// generate boost::program_options object for the routing part +bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &paths) +{ + // declare a group of options that will be allowed only on command line + boost::program_options::options_description generic_options("Options"); + generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")( + "springclean,s", "Remove all regions in shared memory")( + "config,c", boost::program_options::value(&paths["config"]) + ->default_value("server.ini"), + "Path to a configuration file"); + + // declare a group of options that will be allowed both on command line + // as well as in a config file + boost::program_options::options_description config_options("Configuration"); + config_options.add_options()( + "hsgrdata", boost::program_options::value(&paths["hsgrdata"]), + ".hsgr file")("nodesdata", + boost::program_options::value(&paths["nodesdata"]), + ".nodes file")( + "edgesdata", boost::program_options::value(&paths["edgesdata"]), + ".edges file")("geometry", + boost::program_options::value(&paths["geometry"]), + ".geometry file")( + "ramindex", boost::program_options::value(&paths["ramindex"]), + ".ramIndex file")( + "fileindex", boost::program_options::value(&paths["fileindex"]), + ".fileIndex file")( + "namesdata", boost::program_options::value(&paths["namesdata"]), + ".names file")("timestamp", + boost::program_options::value(&paths["timestamp"]), + ".timestamp file"); + + // hidden options, will be allowed both on command line and in config + // file, but will not be shown to the user + boost::program_options::options_description hidden_options("Hidden options"); + hidden_options.add_options()( + "base,b", boost::program_options::value(&paths["base"]), + "base path to .osrm file"); + + // positional option + boost::program_options::positional_options_description positional_options; + positional_options.add("base", 1); + + // combine above options for parsing + boost::program_options::options_description cmdline_options; + cmdline_options.add(generic_options).add(config_options).add(hidden_options); + + boost::program_options::options_description config_file_options; + config_file_options.add(config_options).add(hidden_options); + + boost::program_options::options_description visible_options( + boost::filesystem::basename(argv[0]) + " [] "); + visible_options.add(generic_options).add(config_options); + + // parse command line options + boost::program_options::variables_map option_variables; + boost::program_options::store(boost::program_options::command_line_parser(argc, argv) + .options(cmdline_options) + .positional(positional_options) + .run(), + option_variables); + + if (option_variables.count("version")) + { + SimpleLogger().Write() << g_GIT_DESCRIPTION; + return false; + } + + if (option_variables.count("help")) + { + SimpleLogger().Write() << visible_options; + return false; + } + + boost::program_options::notify(option_variables); + + const bool parameter_present = (paths.find("hsgrdata") != paths.end() && + !paths.find("hsgrdata")->second.string().empty()) || + (paths.find("nodesdata") != paths.end() && + !paths.find("nodesdata")->second.string().empty()) || + (paths.find("edgesdata") != paths.end() && + !paths.find("edgesdata")->second.string().empty()) || + (paths.find("geometry") != paths.end() && + !paths.find("geometry")->second.string().empty()) || + (paths.find("ramindex") != paths.end() && + !paths.find("ramindex")->second.string().empty()) || + (paths.find("fileindex") != paths.end() && + !paths.find("fileindex")->second.string().empty()) || + (paths.find("timestamp") != paths.end() && + !paths.find("timestamp")->second.string().empty()); + + if (parameter_present) + { + if ((paths.find("config") != paths.end() && + boost::filesystem::is_regular_file(paths.find("config")->second)) || + option_variables.count("base")) + { + SimpleLogger().Write(logWARNING) << "conflicting parameters"; + SimpleLogger().Write() << visible_options; + return false; + } + } + + // parse config file + ServerPaths::iterator path_iterator = paths.find("config"); + if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) && + !option_variables.count("base")) + { + SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string(); + std::string ini_file_contents = read_file_lower_content(path_iterator->second); + std::stringstream config_stream(ini_file_contents); + boost::program_options::store(parse_config_file(config_stream, config_file_options), + option_variables); + boost::program_options::notify(option_variables); + } + else if (option_variables.count("base")) + { + path_iterator = paths.find("base"); + BOOST_ASSERT(paths.end() != path_iterator); + std::string base_string = path_iterator->second.string(); + + path_iterator = paths.find("hsgrdata"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".hsgr"; + } + + path_iterator = paths.find("nodesdata"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".nodes"; + } + + path_iterator = paths.find("edgesdata"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".edges"; + } + + path_iterator = paths.find("geometry"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".geometry"; + } + + path_iterator = paths.find("ramindex"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".ramIndex"; + } + + path_iterator = paths.find("fileindex"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".fileIndex"; + } + + path_iterator = paths.find("namesdata"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".names"; + } + + path_iterator = paths.find("timestamp"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".timestamp"; + } + } + + path_iterator = paths.find("hsgrdata"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".hsgr file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("nodesdata"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".nodes file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("edgesdata"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".edges file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("geometry"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".geometry file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("ramindex"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".ramindex file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("fileindex"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".fileindex file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("namesdata"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".names file must be specified"); + } + AssertPathExists(path_iterator->second); + + path_iterator = paths.find("timestamp"); + if (path_iterator == paths.end() || path_iterator->second.string().empty()) + { + throw osrm::exception(".timestamp file must be specified"); + } + + return true; +} + +#endif /* DATASTORE_OPTIONS_HPP */ diff --git a/util/fingerprint.cpp.in b/util/fingerprint.cpp.in new file mode 100644 index 000000000..6f9a6658f --- /dev/null +++ b/util/fingerprint.cpp.in @@ -0,0 +1,103 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "fingerprint.hpp" + +#include "osrm_exception.hpp" + +#include + +#include +#include + +#cmakedefine01 HAS64BITS +#cmakedefine MD5PREPARE "${MD5PREPARE}" +#cmakedefine MD5RTREE "${MD5RTREE}" +#cmakedefine MD5GRAPH "${MD5GRAPH}" +#cmakedefine MD5OBJECTS "${MD5OBJECTS}" + +FingerPrint::FingerPrint() : magic_number(1297240911) +{ + md5_prepare[32] = md5_tree[32] = md5_graph[32] = md5_objects[32] = '\0'; + + boost::uuids::name_generator gen(named_uuid); + std::string temp_string; + + std::memcpy(md5_prepare, MD5PREPARE, strlen(MD5PREPARE)); + temp_string += md5_prepare; + std::memcpy(md5_tree, MD5RTREE, 32); + temp_string += md5_tree; + std::memcpy(md5_graph, MD5GRAPH, 32); + temp_string += md5_graph; + std::memcpy(md5_objects, MD5OBJECTS, 32); + temp_string += md5_objects; + + named_uuid = gen(temp_string); + has_64_bits = HAS64BITS; +} + +FingerPrint::~FingerPrint() {} + +const boost::uuids::uuid &FingerPrint::GetFingerPrint() const { return named_uuid; } + +bool FingerPrint::IsMagicNumberOK() const { return 1297240911 == magic_number; } + +bool FingerPrint::TestGraphUtil(const FingerPrint &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw osrm::exception("hsgr input file misses magic number. Check or reprocess the file"); + } + return std::equal(md5_graph, md5_graph + 32, other.md5_graph); +} + +bool FingerPrint::TestPrepare(const FingerPrint &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw osrm::exception("osrm input file misses magic number. Check or reprocess the file"); + } + return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare); +} + +bool FingerPrint::TestRTree(const FingerPrint &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw osrm::exception("r-tree input file misses magic number. Check or reprocess the file"); + } + return std::equal(md5_tree, md5_tree + 32, other.md5_tree); +} + +bool FingerPrint::TestQueryObjects(const FingerPrint &other) const +{ + if (!other.IsMagicNumberOK()) + { + throw osrm::exception("missing magic number. Check or reprocess the file"); + } + return std::equal(md5_objects, md5_objects + 32, other.md5_objects); +} diff --git a/util/fingerprint.hpp b/util/fingerprint.hpp new file mode 100644 index 000000000..494a877ab --- /dev/null +++ b/util/fingerprint.hpp @@ -0,0 +1,59 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef FINGERPRINT_H +#define FINGERPRINT_H + +#include + +// implements a singleton, i.e. there is one and only one conviguration object +class FingerPrint +{ + public: + FingerPrint(); + FingerPrint(const FingerPrint &) = delete; + ~FingerPrint(); + const boost::uuids::uuid &GetFingerPrint() const; + bool IsMagicNumberOK() const; + bool TestGraphUtil(const FingerPrint &other) const; + bool TestPrepare(const FingerPrint &other) const; + bool TestRTree(const FingerPrint &other) const; + bool TestQueryObjects(const FingerPrint &other) const; + + private: + const unsigned magic_number; + char md5_prepare[33]; + char md5_tree[33]; + char md5_graph[33]; + char md5_objects[33]; + + // initialize to {6ba7b810-9dad-11d1-80b4-00c04fd430c8} + boost::uuids::uuid named_uuid; + bool has_64_bits; +}; + +#endif /* FingerPrint_H */ diff --git a/util/floating_point.hpp b/util/floating_point.hpp new file mode 100644 index 000000000..5c4810279 --- /dev/null +++ b/util/floating_point.hpp @@ -0,0 +1,44 @@ +/* +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef FLOATING_POINT_HPP +#define FLOATING_POINT_HPP + +#include + +#include +#include + +namespace osrm +{ +template bool epsilon_compare(const FloatT number1, const FloatT number2) +{ + static_assert(std::is_floating_point::value, "type must be floating point"); + return (std::abs(number1 - number2) < std::numeric_limits::epsilon()); +} +} + +#endif // FLOATING_POINT_HPP diff --git a/util/git_sha.cpp.in b/util/git_sha.cpp.in new file mode 100644 index 000000000..5b19337e9 --- /dev/null +++ b/util/git_sha.cpp.in @@ -0,0 +1,31 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "git_sha.hpp" + +#define GIT_DESCRIPTION "${GIT_DESCRIPTION}" +char g_GIT_DESCRIPTION[] = GIT_DESCRIPTION; diff --git a/util/git_sha.hpp b/util/git_sha.hpp new file mode 100644 index 000000000..9e55deff3 --- /dev/null +++ b/util/git_sha.hpp @@ -0,0 +1,33 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef GIT_SHA_HPP +#define GIT_SHA_HPP + +extern char g_GIT_DESCRIPTION[]; + +#endif // GIT_SHA_HPP diff --git a/util/graph_loader.hpp b/util/graph_loader.hpp new file mode 100644 index 000000000..44f628034 --- /dev/null +++ b/util/graph_loader.hpp @@ -0,0 +1,320 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef GRAPH_LOADER_HPP +#define GRAPH_LOADER_HPP + +#include "fingerprint.hpp" +#include "osrm_exception.hpp" +#include "simple_logger.hpp" +#include "../data_structures/external_memory_node.hpp" +#include "../data_structures/import_edge.hpp" +#include "../data_structures/query_node.hpp" +#include "../data_structures/restriction.hpp" +#include "../typedefs.h" + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +template +NodeID readBinaryOSRMGraphFromStream(std::istream &input_stream, + std::vector &edge_list, + std::vector &barrier_node_list, + std::vector &traffic_light_node_list, + std::vector *int_to_ext_node_id_map, + std::vector &restriction_list) +{ + const FingerPrint fingerprint_orig; + FingerPrint fingerprint_loaded; + input_stream.read((char *)&fingerprint_loaded, sizeof(FingerPrint)); + + if (!fingerprint_loaded.TestGraphUtil(fingerprint_orig)) + { + SimpleLogger().Write(logWARNING) << ".osrm was prepared with different build.\n" + "Reprocess to get rid of this warning."; + } + + std::unordered_map ext_to_int_id_map; + + NodeID n; + input_stream.read((char *)&n, sizeof(NodeID)); + SimpleLogger().Write() << "Importing n = " << n << " nodes "; + + ExternalMemoryNode current_node; + for (NodeID i = 0; i < n; ++i) + { + input_stream.read((char *)¤t_node, sizeof(ExternalMemoryNode)); + int_to_ext_node_id_map->emplace_back(current_node.lat, current_node.lon, + current_node.node_id); + ext_to_int_id_map.emplace(current_node.node_id, i); + if (current_node.barrier) + { + barrier_node_list.emplace_back(i); + } + if (current_node.traffic_lights) + { + traffic_light_node_list.emplace_back(i); + } + } + + // tighten vector sizes + barrier_node_list.shrink_to_fit(); + traffic_light_node_list.shrink_to_fit(); + + // renumber nodes in turn restrictions + for (TurnRestriction ¤t_restriction : restriction_list) + { + auto internal_id_iter = ext_to_int_id_map.find(current_restriction.from.node); + if (internal_id_iter == ext_to_int_id_map.end()) + { + SimpleLogger().Write(logDEBUG) << "Unmapped from node " << current_restriction.from.node + << " of restriction"; + continue; + } + current_restriction.from.node = internal_id_iter->second; + + internal_id_iter = ext_to_int_id_map.find(current_restriction.via.node); + if (internal_id_iter == ext_to_int_id_map.end()) + { + SimpleLogger().Write(logDEBUG) << "Unmapped via node " << current_restriction.via.node + << " of restriction"; + continue; + } + + current_restriction.via.node = internal_id_iter->second; + + internal_id_iter = ext_to_int_id_map.find(current_restriction.to.node); + if (internal_id_iter == ext_to_int_id_map.end()) + { + SimpleLogger().Write(logDEBUG) << "Unmapped to node " << current_restriction.to.node + << " of restriction"; + continue; + } + current_restriction.to.node = internal_id_iter->second; + } + + EdgeWeight weight; + NodeID source, target; + unsigned nameID; + int length; + short dir; // direction (0 = open, 1 = forward, 2+ = open) + bool is_roundabout, ignore_in_grid, is_access_restricted, is_split; + TravelMode travel_mode; + + EdgeID m; + input_stream.read((char *)&m, sizeof(unsigned)); + edge_list.reserve(m); + SimpleLogger().Write() << " and " << m << " edges "; + + for (EdgeID i = 0; i < m; ++i) + { + input_stream.read((char *)&source, sizeof(unsigned)); + input_stream.read((char *)&target, sizeof(unsigned)); + input_stream.read((char *)&length, sizeof(int)); + input_stream.read((char *)&dir, sizeof(short)); + input_stream.read((char *)&weight, sizeof(int)); + input_stream.read((char *)&nameID, sizeof(unsigned)); + input_stream.read((char *)&is_roundabout, sizeof(bool)); + input_stream.read((char *)&ignore_in_grid, sizeof(bool)); + input_stream.read((char *)&is_access_restricted, sizeof(bool)); + input_stream.read((char *)&travel_mode, sizeof(TravelMode)); + input_stream.read((char *)&is_split, sizeof(bool)); + + BOOST_ASSERT_MSG(length > 0, "loaded null length edge"); + BOOST_ASSERT_MSG(weight > 0, "loaded null weight"); + BOOST_ASSERT_MSG(0 <= dir && dir <= 2, "loaded bogus direction"); + + bool forward = true; + bool backward = true; + if (1 == dir) + { + backward = false; + } + if (2 == dir) + { + forward = false; + } + + // translate the external NodeIDs to internal IDs + auto internal_id_iter = ext_to_int_id_map.find(source); + if (ext_to_int_id_map.find(source) == ext_to_int_id_map.end()) + { +#ifndef NDEBUG + SimpleLogger().Write(logWARNING) << " unresolved source NodeID: " << source; +#endif + continue; + } + source = internal_id_iter->second; + internal_id_iter = ext_to_int_id_map.find(target); + if (ext_to_int_id_map.find(target) == ext_to_int_id_map.end()) + { +#ifndef NDEBUG + SimpleLogger().Write(logWARNING) << "unresolved target NodeID : " << target; +#endif + continue; + } + target = internal_id_iter->second; + BOOST_ASSERT_MSG(source != SPECIAL_NODEID && target != SPECIAL_NODEID, + "nonexisting source or target"); + + if (source > target) + { + std::swap(source, target); + std::swap(forward, backward); + } + + edge_list.emplace_back(source, target, nameID, weight, forward, backward, is_roundabout, + ignore_in_grid, is_access_restricted, travel_mode, is_split); + } + ext_to_int_id_map.clear(); + + tbb::parallel_sort(edge_list.begin(), edge_list.end()); + + for (unsigned i = 1; i < edge_list.size(); ++i) + { + if ((edge_list[i - 1].target == edge_list[i].target) && + (edge_list[i - 1].source == edge_list[i].source)) + { + const bool edge_flags_equivalent = (edge_list[i - 1].forward == edge_list[i].forward) && + (edge_list[i - 1].backward == edge_list[i].backward); + const bool edge_flags_are_superset1 = + (edge_list[i - 1].forward && edge_list[i - 1].backward) && + (edge_list[i].forward != edge_list[i].backward); + const bool edge_flags_are_superset_2 = + (edge_list[i].forward && edge_list[i].backward) && + (edge_list[i - 1].forward != edge_list[i - 1].backward); + + if (edge_flags_equivalent) + { + edge_list[i].weight = std::min(edge_list[i - 1].weight, edge_list[i].weight); + edge_list[i - 1].source = SPECIAL_NODEID; + } + else if (edge_flags_are_superset1) + { + if (edge_list[i - 1].weight <= edge_list[i].weight) + { + // edge i-1 is smaller and goes in both directions. Throw away the other edge + edge_list[i].source = SPECIAL_NODEID; + } + else + { + // edge i-1 is open in both directions, but edge i is smaller in one direction. + // Close edge i-1 in this direction + edge_list[i - 1].forward = !edge_list[i].forward; + edge_list[i - 1].backward = !edge_list[i].backward; + } + } + else if (edge_flags_are_superset_2) + { + if (edge_list[i - 1].weight <= edge_list[i].weight) + { + // edge i-1 is smaller for one direction. edge i is open in both. close edge i + // in the other direction + edge_list[i].forward = !edge_list[i - 1].forward; + edge_list[i].backward = !edge_list[i - 1].backward; + } + else + { + // edge i is smaller and goes in both direction. Throw away edge i-1 + edge_list[i - 1].source = SPECIAL_NODEID; + } + } + } + } + const auto new_end_iter = + std::remove_if(edge_list.begin(), edge_list.end(), [](const EdgeT &edge) + { + return edge.source == SPECIAL_NODEID || edge.target == SPECIAL_NODEID; + }); + edge_list.erase(new_end_iter, edge_list.end()); // remove excess candidates. + edge_list.shrink_to_fit(); + SimpleLogger().Write() << "Graph loaded ok and has " << edge_list.size() << " edges"; + return n; +} + +template +unsigned readHSGRFromStream(const boost::filesystem::path &hsgr_file, + std::vector &node_list, + std::vector &edge_list, + unsigned *check_sum) +{ + if (!boost::filesystem::exists(hsgr_file)) + { + throw osrm::exception("hsgr file does not exist"); + } + if (0 == boost::filesystem::file_size(hsgr_file)) + { + throw osrm::exception("hsgr file is empty"); + } + + boost::filesystem::ifstream hsgr_input_stream(hsgr_file, std::ios::binary); + + FingerPrint fingerprint_loaded, fingerprint_orig; + hsgr_input_stream.read((char *)&fingerprint_loaded, sizeof(FingerPrint)); + if (!fingerprint_loaded.TestGraphUtil(fingerprint_orig)) + { + SimpleLogger().Write(logWARNING) << ".hsgr was prepared with different build.\n" + "Reprocess to get rid of this warning."; + } + + unsigned number_of_nodes = 0; + unsigned number_of_edges = 0; + hsgr_input_stream.read((char *)check_sum, sizeof(unsigned)); + hsgr_input_stream.read((char *)&number_of_nodes, sizeof(unsigned)); + BOOST_ASSERT_MSG(0 != number_of_nodes, "number of nodes is zero"); + hsgr_input_stream.read((char *)&number_of_edges, sizeof(unsigned)); + + SimpleLogger().Write() << "number_of_nodes: " << number_of_nodes + << ", number_of_edges: " << number_of_edges; + + // BOOST_ASSERT_MSG( 0 != number_of_edges, "number of edges is zero"); + node_list.resize(number_of_nodes); + hsgr_input_stream.read((char *)&(node_list[0]), number_of_nodes * sizeof(NodeT)); + + edge_list.resize(number_of_edges); + if (number_of_edges > 0) + { + hsgr_input_stream.read((char *)&(edge_list[0]), number_of_edges * sizeof(EdgeT)); + } + hsgr_input_stream.close(); + + return number_of_nodes; +} + +#endif // GRAPH_LOADER_HPP diff --git a/util/ini_file.hpp b/util/ini_file.hpp new file mode 100644 index 000000000..20616257a --- /dev/null +++ b/util/ini_file.hpp @@ -0,0 +1,51 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef INI_FILE_HPP +#define INI_FILE_HPP + +#include +#include + +#include +#include + +namespace +{ + +// support old capitalized option names by down-casing them with a regex replace +std::string read_file_lower_content(const boost::filesystem::path &path) +{ + boost::filesystem::fstream config_stream(path); + std::string ini_file_content((std::istreambuf_iterator(config_stream)), + std::istreambuf_iterator()); + std::transform(std::begin(ini_file_content), std::end(ini_file_content), + std::begin(ini_file_content), ::tolower); + return ini_file_content; +} +} +#endif // INI_FILE_HPP diff --git a/util/integer_range.hpp b/util/integer_range.hpp new file mode 100644 index 000000000..030b2fa63 --- /dev/null +++ b/util/integer_range.hpp @@ -0,0 +1,70 @@ +/* + +Copyright (c) 2013,2014, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef INTEGER_RANGE_HPP +#define INTEGER_RANGE_HPP + +#include + +namespace osrm +{ + +template class range +{ + private: + Integer last; + Integer iter; + + public: + range(Integer start, Integer end) : last(end), iter(start) + { + static_assert(std::is_integral::value, "range type must be integral"); + } + + // Iterable functions + const range &begin() const { return *this; } + const range &end() const { return *this; } + Integer front() const { return iter; } + Integer back() const { return last - 1; } + + // Iterator functions + bool operator!=(const range &) const { return iter < last; } + void operator++() { ++iter; } + Integer operator*() const { return iter; } +}; + +// convenience function to construct an integer range with type deduction +template +range irange(const Integer first, + const Integer last, + typename std::enable_if::value>::type * = 0) +{ + return range(first, last); +} +} + +#endif // INTEGER_RANGE_HPP diff --git a/util/iterator_range.hpp b/util/iterator_range.hpp new file mode 100644 index 000000000..a057d7c92 --- /dev/null +++ b/util/iterator_range.hpp @@ -0,0 +1,72 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef RANGE_HPP_ +#define RANGE_HPP_ + +namespace osrm +{ +namespace util +{ +template class Range +{ + public: + Range(Iterator begin, Iterator end) : begin_(begin), end_(end) {} + + Iterator begin() const { return begin_; } + Iterator end() const { return end_; } + + private: + Iterator begin_; + Iterator end_; +}; + +// Convenience functions for template parameter inference, +// akin to std::make_pair. + +template Range range(Iterator begin, Iterator end) +{ + return Range(begin, end); +} + +template +Range reverse(Reversable *reversable) +{ + return Range(reversable->rbegin(), reversable->rend()); +} + +template +Range +const_reverse(const ConstReversable *const_reversable) +{ + return Range(const_reversable->crbegin(), + const_reversable->crend()); +} +} +} + +#endif // RANGE_HPP_ diff --git a/util/json_renderer.hpp b/util/json_renderer.hpp new file mode 100644 index 000000000..adb7c544e --- /dev/null +++ b/util/json_renderer.hpp @@ -0,0 +1,184 @@ +/* + +Copyright (c) 2014, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +// based on +// https://svn.apache.org/repos/asf/mesos/tags/release-0.9.0-incubating-RC0/src/common/json.hpp + +#ifndef JSON_RENDERER_HPP +#define JSON_RENDERER_HPP + +#include "cast.hpp" + +#include + +namespace JSON +{ + +struct Renderer : mapbox::util::static_visitor<> +{ + explicit Renderer(std::ostream &_out) : out(_out) {} + + void operator()(const String &string) const { out << "\"" << string.value << "\""; } + + void operator()(const Number &number) const + { + out.precision(10); + out << number.value; + } + + void operator()(const Object &object) const + { + out << "{"; + auto iterator = object.values.begin(); + while (iterator != object.values.end()) + { + out << "\"" << (*iterator).first << "\":"; + mapbox::util::apply_visitor(Renderer(out), (*iterator).second); + if (++iterator != object.values.end()) + { + out << ","; + } + } + out << "}"; + } + + void operator()(const Array &array) const + { + out << "["; + std::vector::const_iterator iterator; + iterator = array.values.begin(); + while (iterator != array.values.end()) + { + mapbox::util::apply_visitor(Renderer(out), *iterator); + if (++iterator != array.values.end()) + { + out << ","; + } + } + out << "]"; + } + + void operator()(const True &) const { out << "true"; } + + void operator()(const False &) const { out << "false"; } + + void operator()(const Null &) const { out << "null"; } + + private: + std::ostream &out; +}; + +struct ArrayRenderer : mapbox::util::static_visitor<> +{ + explicit ArrayRenderer(std::vector &_out) : out(_out) {} + + void operator()(const String &string) const + { + out.push_back('\"'); + out.insert(out.end(), string.value.begin(), string.value.end()); + out.push_back('\"'); + } + + void operator()(const Number &number) const + { + const std::string number_string = cast::double_fixed_to_string(number.value); + out.insert(out.end(), number_string.begin(), number_string.end()); + } + + void operator()(const Object &object) const + { + out.push_back('{'); + auto iterator = object.values.begin(); + while (iterator != object.values.end()) + { + out.push_back('\"'); + out.insert(out.end(), (*iterator).first.begin(), (*iterator).first.end()); + out.push_back('\"'); + out.push_back(':'); + + mapbox::util::apply_visitor(ArrayRenderer(out), (*iterator).second); + if (++iterator != object.values.end()) + { + out.push_back(','); + } + } + out.push_back('}'); + } + + void operator()(const Array &array) const + { + out.push_back('['); + std::vector::const_iterator iterator; + iterator = array.values.begin(); + while (iterator != array.values.end()) + { + mapbox::util::apply_visitor(ArrayRenderer(out), *iterator); + if (++iterator != array.values.end()) + { + out.push_back(','); + } + } + out.push_back(']'); + } + + void operator()(const True &) const + { + const std::string temp("true"); + out.insert(out.end(), temp.begin(), temp.end()); + } + + void operator()(const False &) const + { + const std::string temp("false"); + out.insert(out.end(), temp.begin(), temp.end()); + } + + void operator()(const Null &) const + { + const std::string temp("null"); + out.insert(out.end(), temp.begin(), temp.end()); + } + + private: + std::vector &out; +}; + +inline void render(std::ostream &out, const Object &object) +{ + Value value = object; + mapbox::util::apply_visitor(Renderer(out), value); +} + +inline void render(std::vector &out, const Object &object) +{ + Value value = object; + mapbox::util::apply_visitor(ArrayRenderer(out), value); +} + +} // namespace JSON + +#endif // JSON_RENDERER_HPP diff --git a/util/lua_util.hpp b/util/lua_util.hpp new file mode 100644 index 000000000..f367949da --- /dev/null +++ b/util/lua_util.hpp @@ -0,0 +1,66 @@ +/* + +Copyright (c) 2014, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef LUA_UTIL_HPP +#define LUA_UTIL_HPP + +extern "C" { +#include +#include +#include +} + +#include +#include + +#include +#include + +template void LUA_print(T output) { std::cout << "[LUA] " << output << std::endl; } + +// Check if the lua function is defined +inline bool lua_function_exists(lua_State *lua_state, const char *name) +{ + luabind::object globals_table = luabind::globals(lua_state); + luabind::object lua_function = globals_table[name]; + return lua_function && (luabind::type(lua_function) == LUA_TFUNCTION); +} + +// Add the folder contain the script to the lua load path, so script can easily require() other lua +// scripts inside that folder, or subfolders. +// See http://lua-users.org/wiki/PackagePath for details on the package.path syntax. +inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name) +{ + const boost::filesystem::path profile_path(file_name); + std::string folder = profile_path.parent_path().string(); + // TODO: This code is most probably not Windows safe since it uses UNIX'ish path delimiters + const std::string lua_code = + "package.path = \"" + folder + "/?.lua;profiles/?.lua;\" .. package.path"; + luaL_dostring(lua_state, lua_code.c_str()); +} + +#endif // LUA_UTIL_HPP diff --git a/util/make_unique.hpp b/util/make_unique.hpp new file mode 100644 index 000000000..b88145d17 --- /dev/null +++ b/util/make_unique.hpp @@ -0,0 +1,57 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef MAKE_UNIQUE_H_ +#define MAKE_UNIQUE_H_ + +#include +#include +#include + +namespace osrm +{ +// Taken from http://msdn.microsoft.com/en-us/library/dn439780.asp +// Note, that the snippet was broken there and needed minor massaging + +// make_unique +template std::unique_ptr make_unique(Types &&... Args) +{ + return (std::unique_ptr(new T(std::forward(Args)...))); +} + +// make_unique +template std::unique_ptr make_unique(std::size_t Size) +{ + return (std::unique_ptr(new T[Size]())); +} + +// make_unique disallowed +template +typename std::enable_if::value != 0, void>::type make_unique(Types &&...) = delete; +} + +#endif // MAKE_UNIQUE_H_ diff --git a/util/mercator.cpp b/util/mercator.cpp new file mode 100644 index 000000000..ddd80685d --- /dev/null +++ b/util/mercator.cpp @@ -0,0 +1,40 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "mercator.hpp" + +#include + +double mercator::y2lat(const double value) +{ + return 180. * M_1_PI * (2. * std::atan(std::exp(value * M_PI / 180.)) - M_PI_2); +} + +double mercator::lat2y(const double latitude) +{ + return 180. * M_1_PI * std::log(std::tan(M_PI_4 + latitude * (M_PI / 180.) / 2.)); +} diff --git a/util/mercator.hpp b/util/mercator.hpp new file mode 100644 index 000000000..2929db2f9 --- /dev/null +++ b/util/mercator.hpp @@ -0,0 +1,38 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef MERCATOR_HPP +#define MERCATOR_HPP + +struct mercator +{ + static double y2lat(const double value); + + static double lat2y(const double latitude); +}; + +#endif // MERCATOR_HPP diff --git a/util/osrm_exception.cpp b/util/osrm_exception.cpp new file mode 100644 index 000000000..e6b7986e3 --- /dev/null +++ b/util/osrm_exception.cpp @@ -0,0 +1,43 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "osrm_exception.hpp" + +namespace osrm +{ +// This function exists to 'anchor' the class, and stop the compiler from +// copying vtable and RTTI info into every object file that includes +// this header. (Caught by -Wweak-vtables under Clang.) + +// More information from the LLVM Coding Standards: +// If a class is defined in a header file and has a vtable (either it has +// virtual methods or it derives from classes with virtual methods), it must +// always have at least one out-of-line virtual method in the class. Without +// this, the compiler will copy the vtable and RTTI into every .o file that +// #includes the header, bloating .o file sizes and increasing link times. +void exception::anchor() const {} +} diff --git a/util/osrm_exception.hpp b/util/osrm_exception.hpp new file mode 100644 index 000000000..ac5044a79 --- /dev/null +++ b/util/osrm_exception.hpp @@ -0,0 +1,51 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef OSRM_EXCEPTION_HPP +#define OSRM_EXCEPTION_HPP + +#include +#include + +namespace osrm +{ +class exception final : public std::exception +{ + public: + explicit exception(const char *message) : message(message) {} + explicit exception(const std::string &message) : message(message) {} + + private: + // This function exists to 'anchor' the class, and stop the compiler from + // copying vtable and RTTI info into every object file that includes + // this header. (Caught by -Wweak-vtables under Clang.) + virtual void anchor() const; + const char *what() const noexcept { return message.c_str(); } + const std::string message; +}; +} +#endif /* OSRM_EXCEPTION_HPP */ diff --git a/util/range_algorithms.hpp b/util/range_algorithms.hpp new file mode 100644 index 000000000..5aafd8e17 --- /dev/null +++ b/util/range_algorithms.hpp @@ -0,0 +1,42 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 2010 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. + */ + +#ifndef RANGE_ALGORITHMS_HPP +#define RANGE_ALGORITHMS_HPP + +#include + +namespace osrm +{ + +template +auto max_element(const Container &c) -> decltype(std::max_element(c.begin(), c.end())) +{ + return std::max_element(c.begin(), c.end()); +} + +template +auto max_element(const Container &c) -> decltype(std::max_element(c.cbegin(), c.cend())) +{ + return std::max_element(c.cbegin(), c.cend()); +} +} + +#endif // RANGE_ALGORITHMS_HPP diff --git a/util/routed_options.hpp b/util/routed_options.hpp new file mode 100644 index 000000000..74e79b070 --- /dev/null +++ b/util/routed_options.hpp @@ -0,0 +1,277 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef ROUTED_OPTIONS_HPP +#define ROUTED_OPTIONS_HPP + +#include "git_sha.hpp" +#include "ini_file.hpp" +#include "osrm_exception.hpp" +#include "simple_logger.hpp" + +#include +#include + +#include + +#include +#include +const static unsigned INIT_OK_START_ENGINE = 0; +const static unsigned INIT_OK_DO_NOT_START_ENGINE = 1; +const static unsigned INIT_FAILED = -1; + +inline void populate_base_path(ServerPaths &server_paths) +{ + // populate the server_path object + auto path_iterator = server_paths.find("base"); + + // if a base path has been set, we populate it. + if (path_iterator != server_paths.end()) + { + const std::string base_string = path_iterator->second.string(); + SimpleLogger().Write() << "populating base path: " << base_string; + + server_paths["hsgrdata"] = base_string + ".hsgr"; + BOOST_ASSERT(server_paths.find("hsgrdata") != server_paths.end()); + server_paths["nodesdata"] = base_string + ".nodes"; + BOOST_ASSERT(server_paths.find("nodesdata") != server_paths.end()); + server_paths["edgesdata"] = base_string + ".edges"; + BOOST_ASSERT(server_paths.find("edgesdata") != server_paths.end()); + server_paths["geometries"] = base_string + ".geometry"; + BOOST_ASSERT(server_paths.find("geometries") != server_paths.end()); + server_paths["ramindex"] = base_string + ".ramIndex"; + BOOST_ASSERT(server_paths.find("ramindex") != server_paths.end()); + server_paths["fileindex"] = base_string + ".fileIndex"; + BOOST_ASSERT(server_paths.find("fileindex") != server_paths.end()); + server_paths["namesdata"] = base_string + ".names"; + BOOST_ASSERT(server_paths.find("namesdata") != server_paths.end()); + server_paths["timestamp"] = base_string + ".timestamp"; + BOOST_ASSERT(server_paths.find("timestamp") != server_paths.end()); + } + + // check if files are give and whether they exist at all + path_iterator = server_paths.find("hsgrdata"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + if (path_iterator == server_paths.end()) + { + SimpleLogger().Write() << "hsgrdata unset"; + } + if (!boost::filesystem::is_regular_file(path_iterator->second)) + { + SimpleLogger().Write() << "not a regular file"; + } + + throw osrm::exception(".hsgr not found: " + path_iterator->second.string()); + } + + path_iterator = server_paths.find("nodesdata"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw osrm::exception(".nodes not found"); + } + + path_iterator = server_paths.find("edgesdata"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw osrm::exception(".edges not found"); + } + + path_iterator = server_paths.find("geometries"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw osrm::exception(".geometry not found"); + } + + path_iterator = server_paths.find("ramindex"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw osrm::exception(".ramIndex not found"); + } + + path_iterator = server_paths.find("fileindex"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw osrm::exception(".fileIndex not found"); + } + + path_iterator = server_paths.find("namesdata"); + if (path_iterator == server_paths.end() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw osrm::exception(".namesIndex not found"); + } + + SimpleLogger().Write() << "HSGR file:\t" << server_paths["hsgrdata"]; + SimpleLogger().Write(logDEBUG) << "Nodes file:\t" << server_paths["nodesdata"]; + SimpleLogger().Write(logDEBUG) << "Edges file:\t" << server_paths["edgesdata"]; + SimpleLogger().Write(logDEBUG) << "Geometry file:\t" << server_paths["geometries"]; + SimpleLogger().Write(logDEBUG) << "RAM file:\t" << server_paths["ramindex"]; + SimpleLogger().Write(logDEBUG) << "Index file:\t" << server_paths["fileindex"]; + SimpleLogger().Write(logDEBUG) << "Names file:\t" << server_paths["namesdata"]; + SimpleLogger().Write(logDEBUG) << "Timestamp file:\t" << server_paths["timestamp"]; +} + +// generate boost::program_options object for the routing part +inline unsigned GenerateServerProgramOptions(const int argc, + const char *argv[], + ServerPaths &paths, + std::string &ip_address, + int &ip_port, + int &requested_num_threads, + bool &use_shared_memory, + bool &trial, + int &max_locations_distance_table) +{ + // declare a group of options that will be allowed only on command line + boost::program_options::options_description generic_options("Options"); + generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")( + "config,c", boost::program_options::value(&paths["config"]) + ->default_value("server.ini"), + "Path to a configuration file")( + "trial", boost::program_options::value(&trial)->implicit_value(true), + "Quit after initialization"); + + // declare a group of options that will be allowed both on command line + // as well as in a config file + boost::program_options::options_description config_options("Configuration"); + config_options.add_options()( + "hsgrdata", boost::program_options::value(&paths["hsgrdata"]), + ".hsgr file")("nodesdata", + boost::program_options::value(&paths["nodesdata"]), + ".nodes file")( + "edgesdata", boost::program_options::value(&paths["edgesdata"]), + ".edges file")("geometry", + boost::program_options::value(&paths["geometries"]), + ".geometry file")( + "ramindex", boost::program_options::value(&paths["ramindex"]), + ".ramIndex file")( + "fileindex", boost::program_options::value(&paths["fileindex"]), + "File index file")( + "namesdata", boost::program_options::value(&paths["namesdata"]), + ".names file")("timestamp", + boost::program_options::value(&paths["timestamp"]), + ".timestamp file")( + "ip,i", boost::program_options::value(&ip_address)->default_value("0.0.0.0"), + "IP address")("port,p", boost::program_options::value(&ip_port)->default_value(5000), + "TCP/IP port")( + "threads,t", boost::program_options::value(&requested_num_threads)->default_value(8), + "Number of threads to use")( + "shared-memory,s", + boost::program_options::value(&use_shared_memory)->implicit_value(true), + "Load data from shared memory")( + "max-table-size,m", + boost::program_options::value(&max_locations_distance_table)->default_value(100), + "Max. locations supported in distance table query"); + + // hidden options, will be allowed both on command line and in config + // file, but will not be shown to the user + boost::program_options::options_description hidden_options("Hidden options"); + hidden_options.add_options()( + "base,b", boost::program_options::value(&paths["base"]), + "base path to .osrm file"); + + // positional option + boost::program_options::positional_options_description positional_options; + positional_options.add("base", 1); + + // combine above options for parsing + boost::program_options::options_description cmdline_options; + cmdline_options.add(generic_options).add(config_options).add(hidden_options); + + boost::program_options::options_description config_file_options; + config_file_options.add(config_options).add(hidden_options); + + boost::program_options::options_description visible_options( + boost::filesystem::basename(argv[0]) + " []"); + visible_options.add(generic_options).add(config_options); + + // parse command line options + boost::program_options::variables_map option_variables; + boost::program_options::store(boost::program_options::command_line_parser(argc, argv) + .options(cmdline_options) + .positional(positional_options) + .run(), + option_variables); + + if (option_variables.count("version")) + { + SimpleLogger().Write() << g_GIT_DESCRIPTION; + return INIT_OK_DO_NOT_START_ENGINE; + } + + if (option_variables.count("help")) + { + SimpleLogger().Write() << visible_options; + return INIT_OK_DO_NOT_START_ENGINE; + } + + boost::program_options::notify(option_variables); + + // parse config file + ServerPaths::iterator path_iterator = paths.find("config"); + if (path_iterator != paths.end() && boost::filesystem::is_regular_file(path_iterator->second) && + !option_variables.count("base")) + { + SimpleLogger().Write() << "Reading options from: " << path_iterator->second.string(); + std::string ini_file_contents = read_file_lower_content(path_iterator->second); + std::stringstream config_stream(ini_file_contents); + boost::program_options::store(parse_config_file(config_stream, config_file_options), + option_variables); + boost::program_options::notify(option_variables); + return INIT_OK_START_ENGINE; + } + + if (1 > requested_num_threads) + { + throw osrm::exception("Number of threads must be a positive number"); + } + + if (!use_shared_memory && option_variables.count("base")) + { + return INIT_OK_START_ENGINE; + } + if (use_shared_memory && !option_variables.count("base")) + { + return INIT_OK_START_ENGINE; + } + if (1 > max_locations_distance_table) + { + throw osrm::exception("Max location for distance table must be a positive number"); + } + + SimpleLogger().Write() << visible_options; + return INIT_OK_DO_NOT_START_ENGINE; +} + +#endif // ROUTED_OPTIONS_HPP diff --git a/util/simple_logger.cpp b/util/simple_logger.cpp new file mode 100644 index 000000000..5d8821233 --- /dev/null +++ b/util/simple_logger.cpp @@ -0,0 +1,135 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "simple_logger.hpp" + +#include "osrm_exception.hpp" + +#include + +#include + +#ifdef _MSC_VER +#include +#define isatty _isatty +#define fileno _fileno +#else +#include +#endif + +#include +#include +#include + +namespace +{ +static const char COL_RESET[]{"\x1b[0m"}; +static const char RED[]{"\x1b[31m"}; +#ifndef NDEBUG +static const char YELLOW[]{"\x1b[33m"}; +#endif +// static const char GREEN[] { "\x1b[32m"}; +// static const char BLUE[] { "\x1b[34m"}; +// static const char MAGENTA[] { "\x1b[35m"}; +// static const char CYAN[] { "\x1b[36m"}; +} + +void LogPolicy::Unmute() { m_is_mute = false; } + +void LogPolicy::Mute() { m_is_mute = true; } + +bool LogPolicy::IsMute() const { return m_is_mute; } + +LogPolicy &LogPolicy::GetInstance() +{ + static LogPolicy runningInstance; + return runningInstance; +} + +SimpleLogger::SimpleLogger() : level(logINFO) {} + +std::mutex &SimpleLogger::get_mutex() +{ + static std::mutex mtx; + return mtx; +} + +std::ostringstream &SimpleLogger::Write(LogLevel lvl) +{ + std::lock_guard lock(get_mutex()); + try + { + level = lvl; + os << "["; + switch (level) + { + case logWARNING: + os << "warn"; + break; + case logDEBUG: +#ifndef NDEBUG + os << "debug"; +#endif + break; + default: // logINFO: + os << "info"; + break; + } + os << "] "; + } + catch (const std::exception &e) + { + // encapsulate in osrm::exception + throw osrm::exception(std::string(e.what()) + ", getting ostringstream"); + } + return os; +} + +SimpleLogger::~SimpleLogger() +{ + std::lock_guard lock(get_mutex()); + if (!LogPolicy::GetInstance().IsMute()) + { + const bool is_terminal = static_cast(isatty(fileno(stdout))); + switch (level) + { + case logWARNING: + std::cerr << (is_terminal ? RED : "") << os.str() << (is_terminal ? COL_RESET : "") + << std::endl; + break; + case logDEBUG: +#ifndef NDEBUG + std::cout << (is_terminal ? YELLOW : "") << os.str() << (is_terminal ? COL_RESET : "") + << std::endl; +#endif + break; + default: // logINFO: + std::cout << os.str() << (is_terminal ? COL_RESET : "") << std::endl; + break; + } + } +} diff --git a/util/simple_logger.hpp b/util/simple_logger.hpp new file mode 100644 index 000000000..077fa2e41 --- /dev/null +++ b/util/simple_logger.hpp @@ -0,0 +1,74 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef SIMPLE_LOGGER_HPP +#define SIMPLE_LOGGER_HPP + +#include +#include +#include + +enum LogLevel +{ + logINFO, + logWARNING, + logDEBUG +}; + +class LogPolicy +{ + public: + void Unmute(); + + void Mute(); + + bool IsMute() const; + + static LogPolicy &GetInstance(); + + LogPolicy(const LogPolicy &) = delete; + + private: + LogPolicy() : m_is_mute(true) {} + std::atomic m_is_mute; +}; + +class SimpleLogger +{ + public: + SimpleLogger(); + + virtual ~SimpleLogger(); + std::mutex &get_mutex(); + std::ostringstream &Write(LogLevel l = logINFO); + + private: + std::ostringstream os; + LogLevel level; +}; + +#endif /* SIMPLE_LOGGER_HPP */ diff --git a/util/std_hash.hpp b/util/std_hash.hpp new file mode 100644 index 000000000..8b4af3dd8 --- /dev/null +++ b/util/std_hash.hpp @@ -0,0 +1,72 @@ +/* + +Copyright (c) 2014, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef STD_HASH_HPP +#define STD_HASH_HPP + +#include + +// this is largely inspired by boost's hash combine as can be found in +// "The C++ Standard Library" 2nd Edition. Nicolai M. Josuttis. 2012. + +namespace +{ + +template void hash_combine(std::size_t &seed, const T &val) +{ + seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + +template void hash_val(std::size_t &seed, const T &val) { hash_combine(seed, val); } + +template +void hash_val(std::size_t &seed, const T &val, const Types &... args) +{ + hash_combine(seed, val); + hash_val(seed, args...); +} + +template std::size_t hash_val(const Types &... args) +{ + std::size_t seed = 0; + hash_val(seed, args...); + return seed; +} +} + +namespace std +{ +template struct hash> +{ + size_t operator()(const std::pair &pair) const + { + return hash_val(pair.first, pair.second); + } +}; +} + +#endif // STD_HASH_HPP diff --git a/util/string_util.hpp b/util/string_util.hpp new file mode 100644 index 000000000..08af55483 --- /dev/null +++ b/util/string_util.hpp @@ -0,0 +1,150 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef STRING_UTIL_HPP +#define STRING_UTIL_HPP + +#include + +#include + +#include +#include +#include + +// precision: position after decimal point +// length: maximum number of digits including comma and decimals +// work with negative values to prevent overflowing when taking -value +template static inline char *printInt(char *buffer, int value) +{ + bool minus = true; + if (value > 0) + { + minus = false; + value = -value; + } + buffer += length - 1; + for (int i = 0; i < precision; i++) + { + *buffer = '0' - (value % 10); + value /= 10; + buffer--; + } + *buffer = '.'; + buffer--; + for (int i = precision + 1; i < length; i++) + { + *buffer = '0' - (value % 10); + value /= 10; + if (value == 0) + break; + buffer--; + } + if (minus) + { + buffer--; + *buffer = '-'; + } + return buffer; +} + +inline void replaceAll(std::string &s, const std::string &sub, const std::string &other) +{ + boost::replace_all(s, sub, other); +} + +inline std::string EscapeJSONString(const std::string &input) +{ + std::string output; + output.reserve(input.size()); + for (auto iter = input.begin(); iter != input.end(); ++iter) + { + switch (iter[0]) + { + case '\\': + output += "\\\\"; + break; + case '"': + output += "\\\""; + break; + case '/': + output += "\\/"; + break; + case '\b': + output += "\\b"; + break; + case '\f': + output += "\\f"; + break; + case '\n': + output += "\\n"; + break; + case '\r': + output += "\\r"; + break; + case '\t': + output += "\\t"; + break; + default: + output += *iter; + break; + } + } + return output; +} + +static std::string originals[] = {"&", "\"", "<", ">", "'", "[", "]", "\\"}; +static std::string entities[] = { + "&", """, "<", ">", "'", "&91;", "&93;", " \"}; + +inline std::size_t URIDecode(const std::string &input, std::string &output) +{ + auto src_iter = input.begin(); + output.resize(input.size() + 1); + std::size_t decoded_length = 0; + for (decoded_length = 0; src_iter != input.end(); ++decoded_length) + { + if (src_iter[0] == '%' && src_iter[1] && src_iter[2] && isxdigit(src_iter[1]) && + isxdigit(src_iter[2])) + { + std::string::value_type a = src_iter[1]; + std::string::value_type b = src_iter[2]; + a -= src_iter[1] < 58 ? 48 : src_iter[1] < 71 ? 55 : 87; + b -= src_iter[2] < 58 ? 48 : src_iter[2] < 71 ? 55 : 87; + output[decoded_length] = 16 * a + b; + src_iter += 3; + continue; + } + output[decoded_length] = *src_iter++; + } + output.resize(decoded_length); + return decoded_length; +} + +inline std::size_t URIDecodeInPlace(std::string &URI) { return URIDecode(URI, URI); } + +#endif // STRING_UTIL_HPP diff --git a/util/timing_util.hpp b/util/timing_util.hpp new file mode 100644 index 000000000..2279bd083 --- /dev/null +++ b/util/timing_util.hpp @@ -0,0 +1,90 @@ +/* + +Copyright (c) 2014, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TIMING_UTIL_HPP +#define TIMING_UTIL_HPP + +#include +#include +#include +#include +#include + +struct GlobalTimer +{ + GlobalTimer() : time(0) {} + std::atomic time; +}; + +class GlobalTimerFactory +{ + public: + static GlobalTimerFactory &get() + { + static GlobalTimerFactory instance; + return instance; + } + + GlobalTimer &getGlobalTimer(const std::string &name) + { + std::lock_guard lock(map_mutex); + return timer_map[name]; + } + + private: + std::mutex map_mutex; + std::unordered_map timer_map; +}; + +#define GLOBAL_TIMER_AQUIRE(_X) \ + auto &_X##_global_timer = GlobalTimerFactory::get().getGlobalTimer(#_X) +#define GLOBAL_TIMER_RESET(_X) _X##_global_timer.time = 0 +#define GLOBAL_TIMER_START(_X) TIMER_START(_X) +#define GLOBAL_TIMER_STOP(_X) \ + TIMER_STOP(_X); \ + _X##_global_timer.time += TIMER_NSEC(_X) +#define GLOBAL_TIMER_NSEC(_X) static_cast(_X##_global_timer.time) +#define GLOBAL_TIMER_USEC(_X) (_X##_global_timer.time / 1000.0) +#define GLOBAL_TIMER_MSEC(_X) (_X##_global_timer.time / 1000.0 / 1000.0) +#define GLOBAL_TIMER_SEC(_X) (_X##_global_timer.time / 1000.0 / 1000.0 / 1000.0) + +#define TIMER_START(_X) auto _X##_start = std::chrono::steady_clock::now(), _X##_stop = _X##_start +#define TIMER_STOP(_X) _X##_stop = std::chrono::steady_clock::now() +#define TIMER_NSEC(_X) \ + std::chrono::duration_cast(_X##_stop - _X##_start).count() +#define TIMER_USEC(_X) \ + std::chrono::duration_cast(_X##_stop - _X##_start).count() +#define TIMER_MSEC(_X) \ + (0.000001 * \ + std::chrono::duration_cast(_X##_stop - _X##_start).count()) +#define TIMER_SEC(_X) \ + (0.000001 * \ + std::chrono::duration_cast(_X##_stop - _X##_start).count()) +#define TIMER_MIN(_X) \ + std::chrono::duration_cast(_X##_stop - _X##_start).count() + +#endif // TIMING_UTIL_HPP diff --git a/util/trigonometry_table.hpp b/util/trigonometry_table.hpp new file mode 100644 index 000000000..ebcf7ba4d --- /dev/null +++ b/util/trigonometry_table.hpp @@ -0,0 +1,448 @@ +/* + +Copyright (c) 2015, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TRIGONOMETRY_TABLE_HPP +#define TRIGONOMETRY_TABLE_HPP + +#include "../typedefs.h" +#include + +#include + +constexpr unsigned short atan_table[4096] = { + 0x0000, 0x0014, 0x0028, 0x003d, 0x0051, 0x0065, 0x007a, 0x008e, 0x00a3, 0x00b7, 0x00cb, 0x00e0, + 0x00f4, 0x0108, 0x011d, 0x0131, 0x0146, 0x015a, 0x016e, 0x0183, 0x0197, 0x01ab, 0x01c0, 0x01d4, + 0x01e9, 0x01fd, 0x0211, 0x0226, 0x023a, 0x024e, 0x0263, 0x0277, 0x028c, 0x02a0, 0x02b4, 0x02c9, + 0x02dd, 0x02f1, 0x0306, 0x031a, 0x032f, 0x0343, 0x0357, 0x036c, 0x0380, 0x0394, 0x03a9, 0x03bd, + 0x03d2, 0x03e6, 0x03fa, 0x040f, 0x0423, 0x0437, 0x044c, 0x0460, 0x0475, 0x0489, 0x049d, 0x04b2, + 0x04c6, 0x04da, 0x04ef, 0x0503, 0x0517, 0x052c, 0x0540, 0x0555, 0x0569, 0x057d, 0x0592, 0x05a6, + 0x05ba, 0x05cf, 0x05e3, 0x05f8, 0x060c, 0x0620, 0x0635, 0x0649, 0x065d, 0x0672, 0x0686, 0x069b, + 0x06af, 0x06c3, 0x06d8, 0x06ec, 0x0700, 0x0715, 0x0729, 0x073d, 0x0752, 0x0766, 0x077b, 0x078f, + 0x07a3, 0x07b8, 0x07cc, 0x07e0, 0x07f5, 0x0809, 0x081d, 0x0832, 0x0846, 0x085b, 0x086f, 0x0883, + 0x0898, 0x08ac, 0x08c0, 0x08d5, 0x08e9, 0x08fd, 0x0912, 0x0926, 0x093b, 0x094f, 0x0963, 0x0978, + 0x098c, 0x09a0, 0x09b5, 0x09c9, 0x09dd, 0x09f2, 0x0a06, 0x0a1a, 0x0a2f, 0x0a43, 0x0a58, 0x0a6c, + 0x0a80, 0x0a95, 0x0aa9, 0x0abd, 0x0ad2, 0x0ae6, 0x0afa, 0x0b0f, 0x0b23, 0x0b37, 0x0b4c, 0x0b60, + 0x0b75, 0x0b89, 0x0b9d, 0x0bb2, 0x0bc6, 0x0bda, 0x0bef, 0x0c03, 0x0c17, 0x0c2c, 0x0c40, 0x0c54, + 0x0c69, 0x0c7d, 0x0c91, 0x0ca6, 0x0cba, 0x0cce, 0x0ce3, 0x0cf7, 0x0d0b, 0x0d20, 0x0d34, 0x0d48, + 0x0d5d, 0x0d71, 0x0d86, 0x0d9a, 0x0dae, 0x0dc3, 0x0dd7, 0x0deb, 0x0e00, 0x0e14, 0x0e28, 0x0e3d, + 0x0e51, 0x0e65, 0x0e7a, 0x0e8e, 0x0ea2, 0x0eb7, 0x0ecb, 0x0edf, 0x0ef4, 0x0f08, 0x0f1c, 0x0f31, + 0x0f45, 0x0f59, 0x0f6e, 0x0f82, 0x0f96, 0x0fab, 0x0fbf, 0x0fd3, 0x0fe8, 0x0ffc, 0x1010, 0x1025, + 0x1039, 0x104d, 0x1062, 0x1076, 0x108a, 0x109e, 0x10b3, 0x10c7, 0x10db, 0x10f0, 0x1104, 0x1118, + 0x112d, 0x1141, 0x1155, 0x116a, 0x117e, 0x1192, 0x11a7, 0x11bb, 0x11cf, 0x11e4, 0x11f8, 0x120c, + 0x1221, 0x1235, 0x1249, 0x125d, 0x1272, 0x1286, 0x129a, 0x12af, 0x12c3, 0x12d7, 0x12ec, 0x1300, + 0x1314, 0x1329, 0x133d, 0x1351, 0x1365, 0x137a, 0x138e, 0x13a2, 0x13b7, 0x13cb, 0x13df, 0x13f4, + 0x1408, 0x141c, 0x1431, 0x1445, 0x1459, 0x146d, 0x1482, 0x1496, 0x14aa, 0x14bf, 0x14d3, 0x14e7, + 0x14fb, 0x1510, 0x1524, 0x1538, 0x154d, 0x1561, 0x1575, 0x1589, 0x159e, 0x15b2, 0x15c6, 0x15db, + 0x15ef, 0x1603, 0x1617, 0x162c, 0x1640, 0x1654, 0x1669, 0x167d, 0x1691, 0x16a5, 0x16ba, 0x16ce, + 0x16e2, 0x16f7, 0x170b, 0x171f, 0x1733, 0x1748, 0x175c, 0x1770, 0x1784, 0x1799, 0x17ad, 0x17c1, + 0x17d6, 0x17ea, 0x17fe, 0x1812, 0x1827, 0x183b, 0x184f, 0x1863, 0x1878, 0x188c, 0x18a0, 0x18b4, + 0x18c9, 0x18dd, 0x18f1, 0x1905, 0x191a, 0x192e, 0x1942, 0x1957, 0x196b, 0x197f, 0x1993, 0x19a8, + 0x19bc, 0x19d0, 0x19e4, 0x19f9, 0x1a0d, 0x1a21, 0x1a35, 0x1a49, 0x1a5e, 0x1a72, 0x1a86, 0x1a9a, + 0x1aaf, 0x1ac3, 0x1ad7, 0x1aeb, 0x1b00, 0x1b14, 0x1b28, 0x1b3c, 0x1b51, 0x1b65, 0x1b79, 0x1b8d, + 0x1ba2, 0x1bb6, 0x1bca, 0x1bde, 0x1bf2, 0x1c07, 0x1c1b, 0x1c2f, 0x1c43, 0x1c58, 0x1c6c, 0x1c80, + 0x1c94, 0x1ca8, 0x1cbd, 0x1cd1, 0x1ce5, 0x1cf9, 0x1d0e, 0x1d22, 0x1d36, 0x1d4a, 0x1d5e, 0x1d73, + 0x1d87, 0x1d9b, 0x1daf, 0x1dc3, 0x1dd8, 0x1dec, 0x1e00, 0x1e14, 0x1e28, 0x1e3d, 0x1e51, 0x1e65, + 0x1e79, 0x1e8d, 0x1ea2, 0x1eb6, 0x1eca, 0x1ede, 0x1ef2, 0x1f07, 0x1f1b, 0x1f2f, 0x1f43, 0x1f57, + 0x1f6c, 0x1f80, 0x1f94, 0x1fa8, 0x1fbc, 0x1fd1, 0x1fe5, 0x1ff9, 0x200d, 0x2021, 0x2035, 0x204a, + 0x205e, 0x2072, 0x2086, 0x209a, 0x20ae, 0x20c3, 0x20d7, 0x20eb, 0x20ff, 0x2113, 0x2127, 0x213c, + 0x2150, 0x2164, 0x2178, 0x218c, 0x21a0, 0x21b5, 0x21c9, 0x21dd, 0x21f1, 0x2205, 0x2219, 0x222e, + 0x2242, 0x2256, 0x226a, 0x227e, 0x2292, 0x22a6, 0x22bb, 0x22cf, 0x22e3, 0x22f7, 0x230b, 0x231f, + 0x2333, 0x2348, 0x235c, 0x2370, 0x2384, 0x2398, 0x23ac, 0x23c0, 0x23d5, 0x23e9, 0x23fd, 0x2411, + 0x2425, 0x2439, 0x244d, 0x2461, 0x2476, 0x248a, 0x249e, 0x24b2, 0x24c6, 0x24da, 0x24ee, 0x2502, + 0x2517, 0x252b, 0x253f, 0x2553, 0x2567, 0x257b, 0x258f, 0x25a3, 0x25b7, 0x25cb, 0x25e0, 0x25f4, + 0x2608, 0x261c, 0x2630, 0x2644, 0x2658, 0x266c, 0x2680, 0x2694, 0x26a9, 0x26bd, 0x26d1, 0x26e5, + 0x26f9, 0x270d, 0x2721, 0x2735, 0x2749, 0x275d, 0x2771, 0x2785, 0x279a, 0x27ae, 0x27c2, 0x27d6, + 0x27ea, 0x27fe, 0x2812, 0x2826, 0x283a, 0x284e, 0x2862, 0x2876, 0x288a, 0x289e, 0x28b3, 0x28c7, + 0x28db, 0x28ef, 0x2903, 0x2917, 0x292b, 0x293f, 0x2953, 0x2967, 0x297b, 0x298f, 0x29a3, 0x29b7, + 0x29cb, 0x29df, 0x29f3, 0x2a07, 0x2a1b, 0x2a2f, 0x2a43, 0x2a58, 0x2a6c, 0x2a80, 0x2a94, 0x2aa8, + 0x2abc, 0x2ad0, 0x2ae4, 0x2af8, 0x2b0c, 0x2b20, 0x2b34, 0x2b48, 0x2b5c, 0x2b70, 0x2b84, 0x2b98, + 0x2bac, 0x2bc0, 0x2bd4, 0x2be8, 0x2bfc, 0x2c10, 0x2c24, 0x2c38, 0x2c4c, 0x2c60, 0x2c74, 0x2c88, + 0x2c9c, 0x2cb0, 0x2cc4, 0x2cd8, 0x2cec, 0x2d00, 0x2d14, 0x2d28, 0x2d3c, 0x2d50, 0x2d64, 0x2d78, + 0x2d8c, 0x2da0, 0x2db4, 0x2dc8, 0x2ddc, 0x2df0, 0x2e04, 0x2e18, 0x2e2c, 0x2e40, 0x2e54, 0x2e68, + 0x2e7c, 0x2e90, 0x2ea3, 0x2eb7, 0x2ecb, 0x2edf, 0x2ef3, 0x2f07, 0x2f1b, 0x2f2f, 0x2f43, 0x2f57, + 0x2f6b, 0x2f7f, 0x2f93, 0x2fa7, 0x2fbb, 0x2fcf, 0x2fe3, 0x2ff7, 0x300b, 0x301e, 0x3032, 0x3046, + 0x305a, 0x306e, 0x3082, 0x3096, 0x30aa, 0x30be, 0x30d2, 0x30e6, 0x30fa, 0x310e, 0x3122, 0x3135, + 0x3149, 0x315d, 0x3171, 0x3185, 0x3199, 0x31ad, 0x31c1, 0x31d5, 0x31e9, 0x31fd, 0x3210, 0x3224, + 0x3238, 0x324c, 0x3260, 0x3274, 0x3288, 0x329c, 0x32b0, 0x32c3, 0x32d7, 0x32eb, 0x32ff, 0x3313, + 0x3327, 0x333b, 0x334f, 0x3363, 0x3376, 0x338a, 0x339e, 0x33b2, 0x33c6, 0x33da, 0x33ee, 0x3401, + 0x3415, 0x3429, 0x343d, 0x3451, 0x3465, 0x3479, 0x348c, 0x34a0, 0x34b4, 0x34c8, 0x34dc, 0x34f0, + 0x3504, 0x3517, 0x352b, 0x353f, 0x3553, 0x3567, 0x357b, 0x358e, 0x35a2, 0x35b6, 0x35ca, 0x35de, + 0x35f2, 0x3605, 0x3619, 0x362d, 0x3641, 0x3655, 0x3668, 0x367c, 0x3690, 0x36a4, 0x36b8, 0x36cb, + 0x36df, 0x36f3, 0x3707, 0x371b, 0x372f, 0x3742, 0x3756, 0x376a, 0x377e, 0x3791, 0x37a5, 0x37b9, + 0x37cd, 0x37e1, 0x37f4, 0x3808, 0x381c, 0x3830, 0x3844, 0x3857, 0x386b, 0x387f, 0x3893, 0x38a6, + 0x38ba, 0x38ce, 0x38e2, 0x38f5, 0x3909, 0x391d, 0x3931, 0x3944, 0x3958, 0x396c, 0x3980, 0x3993, + 0x39a7, 0x39bb, 0x39cf, 0x39e2, 0x39f6, 0x3a0a, 0x3a1e, 0x3a31, 0x3a45, 0x3a59, 0x3a6d, 0x3a80, + 0x3a94, 0x3aa8, 0x3abb, 0x3acf, 0x3ae3, 0x3af7, 0x3b0a, 0x3b1e, 0x3b32, 0x3b45, 0x3b59, 0x3b6d, + 0x3b81, 0x3b94, 0x3ba8, 0x3bbc, 0x3bcf, 0x3be3, 0x3bf7, 0x3c0b, 0x3c1e, 0x3c32, 0x3c46, 0x3c59, + 0x3c6d, 0x3c81, 0x3c94, 0x3ca8, 0x3cbc, 0x3ccf, 0x3ce3, 0x3cf7, 0x3d0a, 0x3d1e, 0x3d32, 0x3d45, + 0x3d59, 0x3d6d, 0x3d80, 0x3d94, 0x3da8, 0x3dbb, 0x3dcf, 0x3de3, 0x3df6, 0x3e0a, 0x3e1e, 0x3e31, + 0x3e45, 0x3e59, 0x3e6c, 0x3e80, 0x3e93, 0x3ea7, 0x3ebb, 0x3ece, 0x3ee2, 0x3ef6, 0x3f09, 0x3f1d, + 0x3f30, 0x3f44, 0x3f58, 0x3f6b, 0x3f7f, 0x3f93, 0x3fa6, 0x3fba, 0x3fcd, 0x3fe1, 0x3ff5, 0x4008, + 0x401c, 0x402f, 0x4043, 0x4057, 0x406a, 0x407e, 0x4091, 0x40a5, 0x40b8, 0x40cc, 0x40e0, 0x40f3, + 0x4107, 0x411a, 0x412e, 0x4142, 0x4155, 0x4169, 0x417c, 0x4190, 0x41a3, 0x41b7, 0x41ca, 0x41de, + 0x41f2, 0x4205, 0x4219, 0x422c, 0x4240, 0x4253, 0x4267, 0x427a, 0x428e, 0x42a1, 0x42b5, 0x42c9, + 0x42dc, 0x42f0, 0x4303, 0x4317, 0x432a, 0x433e, 0x4351, 0x4365, 0x4378, 0x438c, 0x439f, 0x43b3, + 0x43c6, 0x43da, 0x43ed, 0x4401, 0x4414, 0x4428, 0x443b, 0x444f, 0x4462, 0x4476, 0x4489, 0x449d, + 0x44b0, 0x44c4, 0x44d7, 0x44eb, 0x44fe, 0x4512, 0x4525, 0x4539, 0x454c, 0x4560, 0x4573, 0x4586, + 0x459a, 0x45ad, 0x45c1, 0x45d4, 0x45e8, 0x45fb, 0x460f, 0x4622, 0x4636, 0x4649, 0x465c, 0x4670, + 0x4683, 0x4697, 0x46aa, 0x46be, 0x46d1, 0x46e5, 0x46f8, 0x470b, 0x471f, 0x4732, 0x4746, 0x4759, + 0x476c, 0x4780, 0x4793, 0x47a7, 0x47ba, 0x47cd, 0x47e1, 0x47f4, 0x4808, 0x481b, 0x482e, 0x4842, + 0x4855, 0x4869, 0x487c, 0x488f, 0x48a3, 0x48b6, 0x48ca, 0x48dd, 0x48f0, 0x4904, 0x4917, 0x492a, + 0x493e, 0x4951, 0x4965, 0x4978, 0x498b, 0x499f, 0x49b2, 0x49c5, 0x49d9, 0x49ec, 0x49ff, 0x4a13, + 0x4a26, 0x4a39, 0x4a4d, 0x4a60, 0x4a73, 0x4a87, 0x4a9a, 0x4aad, 0x4ac1, 0x4ad4, 0x4ae7, 0x4afb, + 0x4b0e, 0x4b21, 0x4b35, 0x4b48, 0x4b5b, 0x4b6f, 0x4b82, 0x4b95, 0x4ba8, 0x4bbc, 0x4bcf, 0x4be2, + 0x4bf6, 0x4c09, 0x4c1c, 0x4c2f, 0x4c43, 0x4c56, 0x4c69, 0x4c7d, 0x4c90, 0x4ca3, 0x4cb6, 0x4cca, + 0x4cdd, 0x4cf0, 0x4d03, 0x4d17, 0x4d2a, 0x4d3d, 0x4d50, 0x4d64, 0x4d77, 0x4d8a, 0x4d9d, 0x4db1, + 0x4dc4, 0x4dd7, 0x4dea, 0x4dfe, 0x4e11, 0x4e24, 0x4e37, 0x4e4b, 0x4e5e, 0x4e71, 0x4e84, 0x4e97, + 0x4eab, 0x4ebe, 0x4ed1, 0x4ee4, 0x4ef7, 0x4f0b, 0x4f1e, 0x4f31, 0x4f44, 0x4f57, 0x4f6b, 0x4f7e, + 0x4f91, 0x4fa4, 0x4fb7, 0x4fcb, 0x4fde, 0x4ff1, 0x5004, 0x5017, 0x502a, 0x503e, 0x5051, 0x5064, + 0x5077, 0x508a, 0x509d, 0x50b1, 0x50c4, 0x50d7, 0x50ea, 0x50fd, 0x5110, 0x5123, 0x5137, 0x514a, + 0x515d, 0x5170, 0x5183, 0x5196, 0x51a9, 0x51bc, 0x51d0, 0x51e3, 0x51f6, 0x5209, 0x521c, 0x522f, + 0x5242, 0x5255, 0x5268, 0x527c, 0x528f, 0x52a2, 0x52b5, 0x52c8, 0x52db, 0x52ee, 0x5301, 0x5314, + 0x5327, 0x533a, 0x534e, 0x5361, 0x5374, 0x5387, 0x539a, 0x53ad, 0x53c0, 0x53d3, 0x53e6, 0x53f9, + 0x540c, 0x541f, 0x5432, 0x5445, 0x5458, 0x546b, 0x547e, 0x5491, 0x54a5, 0x54b8, 0x54cb, 0x54de, + 0x54f1, 0x5504, 0x5517, 0x552a, 0x553d, 0x5550, 0x5563, 0x5576, 0x5589, 0x559c, 0x55af, 0x55c2, + 0x55d5, 0x55e8, 0x55fb, 0x560e, 0x5621, 0x5634, 0x5647, 0x565a, 0x566d, 0x5680, 0x5693, 0x56a6, + 0x56b9, 0x56cb, 0x56de, 0x56f1, 0x5704, 0x5717, 0x572a, 0x573d, 0x5750, 0x5763, 0x5776, 0x5789, + 0x579c, 0x57af, 0x57c2, 0x57d5, 0x57e8, 0x57fb, 0x580e, 0x5820, 0x5833, 0x5846, 0x5859, 0x586c, + 0x587f, 0x5892, 0x58a5, 0x58b8, 0x58cb, 0x58de, 0x58f0, 0x5903, 0x5916, 0x5929, 0x593c, 0x594f, + 0x5962, 0x5975, 0x5988, 0x599a, 0x59ad, 0x59c0, 0x59d3, 0x59e6, 0x59f9, 0x5a0c, 0x5a1f, 0x5a31, + 0x5a44, 0x5a57, 0x5a6a, 0x5a7d, 0x5a90, 0x5aa2, 0x5ab5, 0x5ac8, 0x5adb, 0x5aee, 0x5b01, 0x5b13, + 0x5b26, 0x5b39, 0x5b4c, 0x5b5f, 0x5b72, 0x5b84, 0x5b97, 0x5baa, 0x5bbd, 0x5bd0, 0x5be2, 0x5bf5, + 0x5c08, 0x5c1b, 0x5c2e, 0x5c40, 0x5c53, 0x5c66, 0x5c79, 0x5c8c, 0x5c9e, 0x5cb1, 0x5cc4, 0x5cd7, + 0x5ce9, 0x5cfc, 0x5d0f, 0x5d22, 0x5d34, 0x5d47, 0x5d5a, 0x5d6d, 0x5d7f, 0x5d92, 0x5da5, 0x5db8, + 0x5dca, 0x5ddd, 0x5df0, 0x5e03, 0x5e15, 0x5e28, 0x5e3b, 0x5e4d, 0x5e60, 0x5e73, 0x5e86, 0x5e98, + 0x5eab, 0x5ebe, 0x5ed0, 0x5ee3, 0x5ef6, 0x5f09, 0x5f1b, 0x5f2e, 0x5f41, 0x5f53, 0x5f66, 0x5f79, + 0x5f8b, 0x5f9e, 0x5fb1, 0x5fc3, 0x5fd6, 0x5fe9, 0x5ffb, 0x600e, 0x6021, 0x6033, 0x6046, 0x6059, + 0x606b, 0x607e, 0x6091, 0x60a3, 0x60b6, 0x60c8, 0x60db, 0x60ee, 0x6100, 0x6113, 0x6126, 0x6138, + 0x614b, 0x615d, 0x6170, 0x6183, 0x6195, 0x61a8, 0x61ba, 0x61cd, 0x61e0, 0x61f2, 0x6205, 0x6217, + 0x622a, 0x623d, 0x624f, 0x6262, 0x6274, 0x6287, 0x6299, 0x62ac, 0x62bf, 0x62d1, 0x62e4, 0x62f6, + 0x6309, 0x631b, 0x632e, 0x6340, 0x6353, 0x6366, 0x6378, 0x638b, 0x639d, 0x63b0, 0x63c2, 0x63d5, + 0x63e7, 0x63fa, 0x640c, 0x641f, 0x6431, 0x6444, 0x6456, 0x6469, 0x647b, 0x648e, 0x64a0, 0x64b3, + 0x64c5, 0x64d8, 0x64ea, 0x64fd, 0x650f, 0x6522, 0x6534, 0x6547, 0x6559, 0x656c, 0x657e, 0x6591, + 0x65a3, 0x65b5, 0x65c8, 0x65da, 0x65ed, 0x65ff, 0x6612, 0x6624, 0x6637, 0x6649, 0x665b, 0x666e, + 0x6680, 0x6693, 0x66a5, 0x66b8, 0x66ca, 0x66dc, 0x66ef, 0x6701, 0x6714, 0x6726, 0x6738, 0x674b, + 0x675d, 0x6770, 0x6782, 0x6794, 0x67a7, 0x67b9, 0x67cc, 0x67de, 0x67f0, 0x6803, 0x6815, 0x6827, + 0x683a, 0x684c, 0x685e, 0x6871, 0x6883, 0x6896, 0x68a8, 0x68ba, 0x68cd, 0x68df, 0x68f1, 0x6904, + 0x6916, 0x6928, 0x693b, 0x694d, 0x695f, 0x6972, 0x6984, 0x6996, 0x69a8, 0x69bb, 0x69cd, 0x69df, + 0x69f2, 0x6a04, 0x6a16, 0x6a29, 0x6a3b, 0x6a4d, 0x6a5f, 0x6a72, 0x6a84, 0x6a96, 0x6aa9, 0x6abb, + 0x6acd, 0x6adf, 0x6af2, 0x6b04, 0x6b16, 0x6b28, 0x6b3b, 0x6b4d, 0x6b5f, 0x6b71, 0x6b84, 0x6b96, + 0x6ba8, 0x6bba, 0x6bcd, 0x6bdf, 0x6bf1, 0x6c03, 0x6c15, 0x6c28, 0x6c3a, 0x6c4c, 0x6c5e, 0x6c70, + 0x6c83, 0x6c95, 0x6ca7, 0x6cb9, 0x6ccb, 0x6cde, 0x6cf0, 0x6d02, 0x6d14, 0x6d26, 0x6d39, 0x6d4b, + 0x6d5d, 0x6d6f, 0x6d81, 0x6d93, 0x6da6, 0x6db8, 0x6dca, 0x6ddc, 0x6dee, 0x6e00, 0x6e12, 0x6e25, + 0x6e37, 0x6e49, 0x6e5b, 0x6e6d, 0x6e7f, 0x6e91, 0x6ea3, 0x6eb6, 0x6ec8, 0x6eda, 0x6eec, 0x6efe, + 0x6f10, 0x6f22, 0x6f34, 0x6f46, 0x6f58, 0x6f6b, 0x6f7d, 0x6f8f, 0x6fa1, 0x6fb3, 0x6fc5, 0x6fd7, + 0x6fe9, 0x6ffb, 0x700d, 0x701f, 0x7031, 0x7043, 0x7055, 0x7068, 0x707a, 0x708c, 0x709e, 0x70b0, + 0x70c2, 0x70d4, 0x70e6, 0x70f8, 0x710a, 0x711c, 0x712e, 0x7140, 0x7152, 0x7164, 0x7176, 0x7188, + 0x719a, 0x71ac, 0x71be, 0x71d0, 0x71e2, 0x71f4, 0x7206, 0x7218, 0x722a, 0x723c, 0x724e, 0x7260, + 0x7272, 0x7284, 0x7296, 0x72a8, 0x72ba, 0x72cc, 0x72dd, 0x72ef, 0x7301, 0x7313, 0x7325, 0x7337, + 0x7349, 0x735b, 0x736d, 0x737f, 0x7391, 0x73a3, 0x73b5, 0x73c7, 0x73d8, 0x73ea, 0x73fc, 0x740e, + 0x7420, 0x7432, 0x7444, 0x7456, 0x7468, 0x747a, 0x748b, 0x749d, 0x74af, 0x74c1, 0x74d3, 0x74e5, + 0x74f7, 0x7509, 0x751a, 0x752c, 0x753e, 0x7550, 0x7562, 0x7574, 0x7585, 0x7597, 0x75a9, 0x75bb, + 0x75cd, 0x75df, 0x75f0, 0x7602, 0x7614, 0x7626, 0x7638, 0x764a, 0x765b, 0x766d, 0x767f, 0x7691, + 0x76a3, 0x76b4, 0x76c6, 0x76d8, 0x76ea, 0x76fb, 0x770d, 0x771f, 0x7731, 0x7743, 0x7754, 0x7766, + 0x7778, 0x778a, 0x779b, 0x77ad, 0x77bf, 0x77d1, 0x77e2, 0x77f4, 0x7806, 0x7818, 0x7829, 0x783b, + 0x784d, 0x785e, 0x7870, 0x7882, 0x7894, 0x78a5, 0x78b7, 0x78c9, 0x78da, 0x78ec, 0x78fe, 0x7910, + 0x7921, 0x7933, 0x7945, 0x7956, 0x7968, 0x797a, 0x798b, 0x799d, 0x79af, 0x79c0, 0x79d2, 0x79e4, + 0x79f5, 0x7a07, 0x7a19, 0x7a2a, 0x7a3c, 0x7a4e, 0x7a5f, 0x7a71, 0x7a82, 0x7a94, 0x7aa6, 0x7ab7, + 0x7ac9, 0x7adb, 0x7aec, 0x7afe, 0x7b0f, 0x7b21, 0x7b33, 0x7b44, 0x7b56, 0x7b67, 0x7b79, 0x7b8b, + 0x7b9c, 0x7bae, 0x7bbf, 0x7bd1, 0x7be2, 0x7bf4, 0x7c06, 0x7c17, 0x7c29, 0x7c3a, 0x7c4c, 0x7c5d, + 0x7c6f, 0x7c81, 0x7c92, 0x7ca4, 0x7cb5, 0x7cc7, 0x7cd8, 0x7cea, 0x7cfb, 0x7d0d, 0x7d1e, 0x7d30, + 0x7d41, 0x7d53, 0x7d64, 0x7d76, 0x7d87, 0x7d99, 0x7daa, 0x7dbc, 0x7dcd, 0x7ddf, 0x7df0, 0x7e02, + 0x7e13, 0x7e25, 0x7e36, 0x7e48, 0x7e59, 0x7e6b, 0x7e7c, 0x7e8e, 0x7e9f, 0x7eb0, 0x7ec2, 0x7ed3, + 0x7ee5, 0x7ef6, 0x7f08, 0x7f19, 0x7f2b, 0x7f3c, 0x7f4d, 0x7f5f, 0x7f70, 0x7f82, 0x7f93, 0x7fa4, + 0x7fb6, 0x7fc7, 0x7fd9, 0x7fea, 0x7ffb, 0x800d, 0x801e, 0x8030, 0x8041, 0x8052, 0x8064, 0x8075, + 0x8086, 0x8098, 0x80a9, 0x80bb, 0x80cc, 0x80dd, 0x80ef, 0x8100, 0x8111, 0x8123, 0x8134, 0x8145, + 0x8157, 0x8168, 0x8179, 0x818b, 0x819c, 0x81ad, 0x81bf, 0x81d0, 0x81e1, 0x81f3, 0x8204, 0x8215, + 0x8226, 0x8238, 0x8249, 0x825a, 0x826c, 0x827d, 0x828e, 0x829f, 0x82b1, 0x82c2, 0x82d3, 0x82e5, + 0x82f6, 0x8307, 0x8318, 0x832a, 0x833b, 0x834c, 0x835d, 0x836f, 0x8380, 0x8391, 0x83a2, 0x83b3, + 0x83c5, 0x83d6, 0x83e7, 0x83f8, 0x840a, 0x841b, 0x842c, 0x843d, 0x844e, 0x8460, 0x8471, 0x8482, + 0x8493, 0x84a4, 0x84b6, 0x84c7, 0x84d8, 0x84e9, 0x84fa, 0x850b, 0x851d, 0x852e, 0x853f, 0x8550, + 0x8561, 0x8572, 0x8584, 0x8595, 0x85a6, 0x85b7, 0x85c8, 0x85d9, 0x85ea, 0x85fb, 0x860d, 0x861e, + 0x862f, 0x8640, 0x8651, 0x8662, 0x8673, 0x8684, 0x8695, 0x86a7, 0x86b8, 0x86c9, 0x86da, 0x86eb, + 0x86fc, 0x870d, 0x871e, 0x872f, 0x8740, 0x8751, 0x8762, 0x8773, 0x8784, 0x8796, 0x87a7, 0x87b8, + 0x87c9, 0x87da, 0x87eb, 0x87fc, 0x880d, 0x881e, 0x882f, 0x8840, 0x8851, 0x8862, 0x8873, 0x8884, + 0x8895, 0x88a6, 0x88b7, 0x88c8, 0x88d9, 0x88ea, 0x88fb, 0x890c, 0x891d, 0x892e, 0x893f, 0x8950, + 0x8961, 0x8972, 0x8983, 0x8994, 0x89a5, 0x89b6, 0x89c6, 0x89d7, 0x89e8, 0x89f9, 0x8a0a, 0x8a1b, + 0x8a2c, 0x8a3d, 0x8a4e, 0x8a5f, 0x8a70, 0x8a81, 0x8a92, 0x8aa3, 0x8ab3, 0x8ac4, 0x8ad5, 0x8ae6, + 0x8af7, 0x8b08, 0x8b19, 0x8b2a, 0x8b3b, 0x8b4b, 0x8b5c, 0x8b6d, 0x8b7e, 0x8b8f, 0x8ba0, 0x8bb1, + 0x8bc1, 0x8bd2, 0x8be3, 0x8bf4, 0x8c05, 0x8c16, 0x8c27, 0x8c37, 0x8c48, 0x8c59, 0x8c6a, 0x8c7b, + 0x8c8c, 0x8c9c, 0x8cad, 0x8cbe, 0x8ccf, 0x8ce0, 0x8cf0, 0x8d01, 0x8d12, 0x8d23, 0x8d34, 0x8d44, + 0x8d55, 0x8d66, 0x8d77, 0x8d87, 0x8d98, 0x8da9, 0x8dba, 0x8dca, 0x8ddb, 0x8dec, 0x8dfd, 0x8e0d, + 0x8e1e, 0x8e2f, 0x8e40, 0x8e50, 0x8e61, 0x8e72, 0x8e83, 0x8e93, 0x8ea4, 0x8eb5, 0x8ec5, 0x8ed6, + 0x8ee7, 0x8ef8, 0x8f08, 0x8f19, 0x8f2a, 0x8f3a, 0x8f4b, 0x8f5c, 0x8f6c, 0x8f7d, 0x8f8e, 0x8f9e, + 0x8faf, 0x8fc0, 0x8fd0, 0x8fe1, 0x8ff2, 0x9002, 0x9013, 0x9024, 0x9034, 0x9045, 0x9056, 0x9066, + 0x9077, 0x9088, 0x9098, 0x90a9, 0x90b9, 0x90ca, 0x90db, 0x90eb, 0x90fc, 0x910c, 0x911d, 0x912e, + 0x913e, 0x914f, 0x915f, 0x9170, 0x9181, 0x9191, 0x91a2, 0x91b2, 0x91c3, 0x91d3, 0x91e4, 0x91f5, + 0x9205, 0x9216, 0x9226, 0x9237, 0x9247, 0x9258, 0x9268, 0x9279, 0x9289, 0x929a, 0x92aa, 0x92bb, + 0x92cc, 0x92dc, 0x92ed, 0x92fd, 0x930e, 0x931e, 0x932f, 0x933f, 0x9350, 0x9360, 0x9370, 0x9381, + 0x9391, 0x93a2, 0x93b2, 0x93c3, 0x93d3, 0x93e4, 0x93f4, 0x9405, 0x9415, 0x9426, 0x9436, 0x9447, + 0x9457, 0x9467, 0x9478, 0x9488, 0x9499, 0x94a9, 0x94ba, 0x94ca, 0x94da, 0x94eb, 0x94fb, 0x950c, + 0x951c, 0x952c, 0x953d, 0x954d, 0x955e, 0x956e, 0x957e, 0x958f, 0x959f, 0x95af, 0x95c0, 0x95d0, + 0x95e1, 0x95f1, 0x9601, 0x9612, 0x9622, 0x9632, 0x9643, 0x9653, 0x9663, 0x9674, 0x9684, 0x9694, + 0x96a5, 0x96b5, 0x96c5, 0x96d6, 0x96e6, 0x96f6, 0x9707, 0x9717, 0x9727, 0x9738, 0x9748, 0x9758, + 0x9768, 0x9779, 0x9789, 0x9799, 0x97aa, 0x97ba, 0x97ca, 0x97da, 0x97eb, 0x97fb, 0x980b, 0x981b, + 0x982c, 0x983c, 0x984c, 0x985c, 0x986d, 0x987d, 0x988d, 0x989d, 0x98ad, 0x98be, 0x98ce, 0x98de, + 0x98ee, 0x98ff, 0x990f, 0x991f, 0x992f, 0x993f, 0x9950, 0x9960, 0x9970, 0x9980, 0x9990, 0x99a0, + 0x99b1, 0x99c1, 0x99d1, 0x99e1, 0x99f1, 0x9a01, 0x9a12, 0x9a22, 0x9a32, 0x9a42, 0x9a52, 0x9a62, + 0x9a72, 0x9a83, 0x9a93, 0x9aa3, 0x9ab3, 0x9ac3, 0x9ad3, 0x9ae3, 0x9af3, 0x9b04, 0x9b14, 0x9b24, + 0x9b34, 0x9b44, 0x9b54, 0x9b64, 0x9b74, 0x9b84, 0x9b94, 0x9ba4, 0x9bb5, 0x9bc5, 0x9bd5, 0x9be5, + 0x9bf5, 0x9c05, 0x9c15, 0x9c25, 0x9c35, 0x9c45, 0x9c55, 0x9c65, 0x9c75, 0x9c85, 0x9c95, 0x9ca5, + 0x9cb5, 0x9cc5, 0x9cd5, 0x9ce5, 0x9cf5, 0x9d05, 0x9d15, 0x9d25, 0x9d35, 0x9d45, 0x9d55, 0x9d65, + 0x9d75, 0x9d85, 0x9d95, 0x9da5, 0x9db5, 0x9dc5, 0x9dd5, 0x9de5, 0x9df5, 0x9e05, 0x9e15, 0x9e25, + 0x9e35, 0x9e45, 0x9e55, 0x9e65, 0x9e74, 0x9e84, 0x9e94, 0x9ea4, 0x9eb4, 0x9ec4, 0x9ed4, 0x9ee4, + 0x9ef4, 0x9f04, 0x9f14, 0x9f23, 0x9f33, 0x9f43, 0x9f53, 0x9f63, 0x9f73, 0x9f83, 0x9f93, 0x9fa3, + 0x9fb2, 0x9fc2, 0x9fd2, 0x9fe2, 0x9ff2, 0xa002, 0xa012, 0xa021, 0xa031, 0xa041, 0xa051, 0xa061, + 0xa071, 0xa080, 0xa090, 0xa0a0, 0xa0b0, 0xa0c0, 0xa0cf, 0xa0df, 0xa0ef, 0xa0ff, 0xa10f, 0xa11e, + 0xa12e, 0xa13e, 0xa14e, 0xa15e, 0xa16d, 0xa17d, 0xa18d, 0xa19d, 0xa1ac, 0xa1bc, 0xa1cc, 0xa1dc, + 0xa1eb, 0xa1fb, 0xa20b, 0xa21b, 0xa22a, 0xa23a, 0xa24a, 0xa25a, 0xa269, 0xa279, 0xa289, 0xa298, + 0xa2a8, 0xa2b8, 0xa2c8, 0xa2d7, 0xa2e7, 0xa2f7, 0xa306, 0xa316, 0xa326, 0xa335, 0xa345, 0xa355, + 0xa364, 0xa374, 0xa384, 0xa393, 0xa3a3, 0xa3b3, 0xa3c2, 0xa3d2, 0xa3e2, 0xa3f1, 0xa401, 0xa411, + 0xa420, 0xa430, 0xa440, 0xa44f, 0xa45f, 0xa46e, 0xa47e, 0xa48e, 0xa49d, 0xa4ad, 0xa4bc, 0xa4cc, + 0xa4dc, 0xa4eb, 0xa4fb, 0xa50a, 0xa51a, 0xa52a, 0xa539, 0xa549, 0xa558, 0xa568, 0xa577, 0xa587, + 0xa597, 0xa5a6, 0xa5b6, 0xa5c5, 0xa5d5, 0xa5e4, 0xa5f4, 0xa603, 0xa613, 0xa622, 0xa632, 0xa641, + 0xa651, 0xa660, 0xa670, 0xa67f, 0xa68f, 0xa69e, 0xa6ae, 0xa6bd, 0xa6cd, 0xa6dc, 0xa6ec, 0xa6fb, + 0xa70b, 0xa71a, 0xa72a, 0xa739, 0xa749, 0xa758, 0xa768, 0xa777, 0xa787, 0xa796, 0xa7a5, 0xa7b5, + 0xa7c4, 0xa7d4, 0xa7e3, 0xa7f3, 0xa802, 0xa812, 0xa821, 0xa830, 0xa840, 0xa84f, 0xa85f, 0xa86e, + 0xa87d, 0xa88d, 0xa89c, 0xa8ac, 0xa8bb, 0xa8ca, 0xa8da, 0xa8e9, 0xa8f8, 0xa908, 0xa917, 0xa927, + 0xa936, 0xa945, 0xa955, 0xa964, 0xa973, 0xa983, 0xa992, 0xa9a1, 0xa9b1, 0xa9c0, 0xa9cf, 0xa9df, + 0xa9ee, 0xa9fd, 0xaa0d, 0xaa1c, 0xaa2b, 0xaa3b, 0xaa4a, 0xaa59, 0xaa69, 0xaa78, 0xaa87, 0xaa96, + 0xaaa6, 0xaab5, 0xaac4, 0xaad4, 0xaae3, 0xaaf2, 0xab01, 0xab11, 0xab20, 0xab2f, 0xab3e, 0xab4e, + 0xab5d, 0xab6c, 0xab7b, 0xab8b, 0xab9a, 0xaba9, 0xabb8, 0xabc7, 0xabd7, 0xabe6, 0xabf5, 0xac04, + 0xac14, 0xac23, 0xac32, 0xac41, 0xac50, 0xac60, 0xac6f, 0xac7e, 0xac8d, 0xac9c, 0xacab, 0xacbb, + 0xacca, 0xacd9, 0xace8, 0xacf7, 0xad06, 0xad16, 0xad25, 0xad34, 0xad43, 0xad52, 0xad61, 0xad70, + 0xad80, 0xad8f, 0xad9e, 0xadad, 0xadbc, 0xadcb, 0xadda, 0xade9, 0xadf8, 0xae08, 0xae17, 0xae26, + 0xae35, 0xae44, 0xae53, 0xae62, 0xae71, 0xae80, 0xae8f, 0xae9e, 0xaead, 0xaebd, 0xaecc, 0xaedb, + 0xaeea, 0xaef9, 0xaf08, 0xaf17, 0xaf26, 0xaf35, 0xaf44, 0xaf53, 0xaf62, 0xaf71, 0xaf80, 0xaf8f, + 0xaf9e, 0xafad, 0xafbc, 0xafcb, 0xafda, 0xafe9, 0xaff8, 0xb007, 0xb016, 0xb025, 0xb034, 0xb043, + 0xb052, 0xb061, 0xb070, 0xb07f, 0xb08e, 0xb09d, 0xb0ac, 0xb0bb, 0xb0ca, 0xb0d9, 0xb0e8, 0xb0f6, + 0xb105, 0xb114, 0xb123, 0xb132, 0xb141, 0xb150, 0xb15f, 0xb16e, 0xb17d, 0xb18c, 0xb19b, 0xb1aa, + 0xb1b8, 0xb1c7, 0xb1d6, 0xb1e5, 0xb1f4, 0xb203, 0xb212, 0xb221, 0xb22f, 0xb23e, 0xb24d, 0xb25c, + 0xb26b, 0xb27a, 0xb289, 0xb297, 0xb2a6, 0xb2b5, 0xb2c4, 0xb2d3, 0xb2e2, 0xb2f1, 0xb2ff, 0xb30e, + 0xb31d, 0xb32c, 0xb33b, 0xb349, 0xb358, 0xb367, 0xb376, 0xb385, 0xb393, 0xb3a2, 0xb3b1, 0xb3c0, + 0xb3cf, 0xb3dd, 0xb3ec, 0xb3fb, 0xb40a, 0xb418, 0xb427, 0xb436, 0xb445, 0xb453, 0xb462, 0xb471, + 0xb480, 0xb48e, 0xb49d, 0xb4ac, 0xb4bb, 0xb4c9, 0xb4d8, 0xb4e7, 0xb4f6, 0xb504, 0xb513, 0xb522, + 0xb530, 0xb53f, 0xb54e, 0xb55c, 0xb56b, 0xb57a, 0xb588, 0xb597, 0xb5a6, 0xb5b5, 0xb5c3, 0xb5d2, + 0xb5e1, 0xb5ef, 0xb5fe, 0xb60d, 0xb61b, 0xb62a, 0xb638, 0xb647, 0xb656, 0xb664, 0xb673, 0xb682, + 0xb690, 0xb69f, 0xb6ae, 0xb6bc, 0xb6cb, 0xb6d9, 0xb6e8, 0xb6f7, 0xb705, 0xb714, 0xb722, 0xb731, + 0xb740, 0xb74e, 0xb75d, 0xb76b, 0xb77a, 0xb788, 0xb797, 0xb7a6, 0xb7b4, 0xb7c3, 0xb7d1, 0xb7e0, + 0xb7ee, 0xb7fd, 0xb80b, 0xb81a, 0xb829, 0xb837, 0xb846, 0xb854, 0xb863, 0xb871, 0xb880, 0xb88e, + 0xb89d, 0xb8ab, 0xb8ba, 0xb8c8, 0xb8d7, 0xb8e5, 0xb8f4, 0xb902, 0xb911, 0xb91f, 0xb92e, 0xb93c, + 0xb94b, 0xb959, 0xb968, 0xb976, 0xb984, 0xb993, 0xb9a1, 0xb9b0, 0xb9be, 0xb9cd, 0xb9db, 0xb9ea, + 0xb9f8, 0xba06, 0xba15, 0xba23, 0xba32, 0xba40, 0xba4f, 0xba5d, 0xba6b, 0xba7a, 0xba88, 0xba97, + 0xbaa5, 0xbab3, 0xbac2, 0xbad0, 0xbade, 0xbaed, 0xbafb, 0xbb0a, 0xbb18, 0xbb26, 0xbb35, 0xbb43, + 0xbb51, 0xbb60, 0xbb6e, 0xbb7c, 0xbb8b, 0xbb99, 0xbba8, 0xbbb6, 0xbbc4, 0xbbd3, 0xbbe1, 0xbbef, + 0xbbfd, 0xbc0c, 0xbc1a, 0xbc28, 0xbc37, 0xbc45, 0xbc53, 0xbc62, 0xbc70, 0xbc7e, 0xbc8c, 0xbc9b, + 0xbca9, 0xbcb7, 0xbcc6, 0xbcd4, 0xbce2, 0xbcf0, 0xbcff, 0xbd0d, 0xbd1b, 0xbd29, 0xbd38, 0xbd46, + 0xbd54, 0xbd62, 0xbd71, 0xbd7f, 0xbd8d, 0xbd9b, 0xbdaa, 0xbdb8, 0xbdc6, 0xbdd4, 0xbde2, 0xbdf1, + 0xbdff, 0xbe0d, 0xbe1b, 0xbe29, 0xbe38, 0xbe46, 0xbe54, 0xbe62, 0xbe70, 0xbe7f, 0xbe8d, 0xbe9b, + 0xbea9, 0xbeb7, 0xbec5, 0xbed4, 0xbee2, 0xbef0, 0xbefe, 0xbf0c, 0xbf1a, 0xbf28, 0xbf37, 0xbf45, + 0xbf53, 0xbf61, 0xbf6f, 0xbf7d, 0xbf8b, 0xbf99, 0xbfa7, 0xbfb6, 0xbfc4, 0xbfd2, 0xbfe0, 0xbfee, + 0xbffc, 0xc00a, 0xc018, 0xc026, 0xc034, 0xc042, 0xc051, 0xc05f, 0xc06d, 0xc07b, 0xc089, 0xc097, + 0xc0a5, 0xc0b3, 0xc0c1, 0xc0cf, 0xc0dd, 0xc0eb, 0xc0f9, 0xc107, 0xc115, 0xc123, 0xc131, 0xc13f, + 0xc14d, 0xc15b, 0xc169, 0xc177, 0xc185, 0xc193, 0xc1a1, 0xc1af, 0xc1bd, 0xc1cb, 0xc1d9, 0xc1e7, + 0xc1f5, 0xc203, 0xc211, 0xc21f, 0xc22d, 0xc23b, 0xc249, 0xc257, 0xc265, 0xc273, 0xc281, 0xc28f, + 0xc29d, 0xc2ab, 0xc2b8, 0xc2c6, 0xc2d4, 0xc2e2, 0xc2f0, 0xc2fe, 0xc30c, 0xc31a, 0xc328, 0xc336, + 0xc344, 0xc352, 0xc35f, 0xc36d, 0xc37b, 0xc389, 0xc397, 0xc3a5, 0xc3b3, 0xc3c1, 0xc3ce, 0xc3dc, + 0xc3ea, 0xc3f8, 0xc406, 0xc414, 0xc422, 0xc42f, 0xc43d, 0xc44b, 0xc459, 0xc467, 0xc475, 0xc482, + 0xc490, 0xc49e, 0xc4ac, 0xc4ba, 0xc4c7, 0xc4d5, 0xc4e3, 0xc4f1, 0xc4ff, 0xc50d, 0xc51a, 0xc528, + 0xc536, 0xc544, 0xc551, 0xc55f, 0xc56d, 0xc57b, 0xc589, 0xc596, 0xc5a4, 0xc5b2, 0xc5c0, 0xc5cd, + 0xc5db, 0xc5e9, 0xc5f7, 0xc604, 0xc612, 0xc620, 0xc62d, 0xc63b, 0xc649, 0xc657, 0xc664, 0xc672, + 0xc680, 0xc68d, 0xc69b, 0xc6a9, 0xc6b7, 0xc6c4, 0xc6d2, 0xc6e0, 0xc6ed, 0xc6fb, 0xc709, 0xc716, + 0xc724, 0xc732, 0xc73f, 0xc74d, 0xc75b, 0xc768, 0xc776, 0xc784, 0xc791, 0xc79f, 0xc7ad, 0xc7ba, + 0xc7c8, 0xc7d6, 0xc7e3, 0xc7f1, 0xc7fe, 0xc80c, 0xc81a, 0xc827, 0xc835, 0xc842, 0xc850, 0xc85e, + 0xc86b, 0xc879, 0xc886, 0xc894, 0xc8a2, 0xc8af, 0xc8bd, 0xc8ca, 0xc8d8, 0xc8e5, 0xc8f3, 0xc901, + 0xc90e, 0xc91c, 0xc929, 0xc937, 0xc944, 0xc952, 0xc95f, 0xc96d, 0xc97b, 0xc988, 0xc996, 0xc9a3, + 0xc9b1, 0xc9be, 0xc9cc, 0xc9d9, 0xc9e7, 0xc9f4, 0xca02, 0xca0f, 0xca1d, 0xca2a, 0xca38, 0xca45, + 0xca53, 0xca60, 0xca6e, 0xca7b, 0xca89, 0xca96, 0xcaa4, 0xcab1, 0xcabe, 0xcacc, 0xcad9, 0xcae7, + 0xcaf4, 0xcb02, 0xcb0f, 0xcb1d, 0xcb2a, 0xcb37, 0xcb45, 0xcb52, 0xcb60, 0xcb6d, 0xcb7b, 0xcb88, + 0xcb95, 0xcba3, 0xcbb0, 0xcbbe, 0xcbcb, 0xcbd8, 0xcbe6, 0xcbf3, 0xcc01, 0xcc0e, 0xcc1b, 0xcc29, + 0xcc36, 0xcc43, 0xcc51, 0xcc5e, 0xcc6c, 0xcc79, 0xcc86, 0xcc94, 0xcca1, 0xccae, 0xccbc, 0xccc9, + 0xccd6, 0xcce4, 0xccf1, 0xccfe, 0xcd0c, 0xcd19, 0xcd26, 0xcd34, 0xcd41, 0xcd4e, 0xcd5b, 0xcd69, + 0xcd76, 0xcd83, 0xcd91, 0xcd9e, 0xcdab, 0xcdb9, 0xcdc6, 0xcdd3, 0xcde0, 0xcdee, 0xcdfb, 0xce08, + 0xce15, 0xce23, 0xce30, 0xce3d, 0xce4a, 0xce58, 0xce65, 0xce72, 0xce7f, 0xce8d, 0xce9a, 0xcea7, + 0xceb4, 0xcec2, 0xcecf, 0xcedc, 0xcee9, 0xcef6, 0xcf04, 0xcf11, 0xcf1e, 0xcf2b, 0xcf38, 0xcf46, + 0xcf53, 0xcf60, 0xcf6d, 0xcf7a, 0xcf87, 0xcf95, 0xcfa2, 0xcfaf, 0xcfbc, 0xcfc9, 0xcfd6, 0xcfe4, + 0xcff1, 0xcffe, 0xd00b, 0xd018, 0xd025, 0xd032, 0xd040, 0xd04d, 0xd05a, 0xd067, 0xd074, 0xd081, + 0xd08e, 0xd09b, 0xd0a9, 0xd0b6, 0xd0c3, 0xd0d0, 0xd0dd, 0xd0ea, 0xd0f7, 0xd104, 0xd111, 0xd11e, + 0xd12b, 0xd139, 0xd146, 0xd153, 0xd160, 0xd16d, 0xd17a, 0xd187, 0xd194, 0xd1a1, 0xd1ae, 0xd1bb, + 0xd1c8, 0xd1d5, 0xd1e2, 0xd1ef, 0xd1fc, 0xd209, 0xd216, 0xd223, 0xd230, 0xd23d, 0xd24a, 0xd257, + 0xd264, 0xd271, 0xd27e, 0xd28b, 0xd298, 0xd2a5, 0xd2b2, 0xd2bf, 0xd2cc, 0xd2d9, 0xd2e6, 0xd2f3, + 0xd300, 0xd30d, 0xd31a, 0xd327, 0xd334, 0xd341, 0xd34e, 0xd35b, 0xd368, 0xd375, 0xd382, 0xd38f, + 0xd39c, 0xd3a8, 0xd3b5, 0xd3c2, 0xd3cf, 0xd3dc, 0xd3e9, 0xd3f6, 0xd403, 0xd410, 0xd41d, 0xd42a, + 0xd436, 0xd443, 0xd450, 0xd45d, 0xd46a, 0xd477, 0xd484, 0xd491, 0xd49e, 0xd4aa, 0xd4b7, 0xd4c4, + 0xd4d1, 0xd4de, 0xd4eb, 0xd4f8, 0xd504, 0xd511, 0xd51e, 0xd52b, 0xd538, 0xd545, 0xd551, 0xd55e, + 0xd56b, 0xd578, 0xd585, 0xd591, 0xd59e, 0xd5ab, 0xd5b8, 0xd5c5, 0xd5d1, 0xd5de, 0xd5eb, 0xd5f8, + 0xd605, 0xd611, 0xd61e, 0xd62b, 0xd638, 0xd645, 0xd651, 0xd65e, 0xd66b, 0xd678, 0xd684, 0xd691, + 0xd69e, 0xd6ab, 0xd6b7, 0xd6c4, 0xd6d1, 0xd6de, 0xd6ea, 0xd6f7, 0xd704, 0xd710, 0xd71d, 0xd72a, + 0xd737, 0xd743, 0xd750, 0xd75d, 0xd769, 0xd776, 0xd783, 0xd78f, 0xd79c, 0xd7a9, 0xd7b6, 0xd7c2, + 0xd7cf, 0xd7dc, 0xd7e8, 0xd7f5, 0xd802, 0xd80e, 0xd81b, 0xd828, 0xd834, 0xd841, 0xd84e, 0xd85a, + 0xd867, 0xd873, 0xd880, 0xd88d, 0xd899, 0xd8a6, 0xd8b3, 0xd8bf, 0xd8cc, 0xd8d8, 0xd8e5, 0xd8f2, + 0xd8fe, 0xd90b, 0xd917, 0xd924, 0xd931, 0xd93d, 0xd94a, 0xd956, 0xd963, 0xd970, 0xd97c, 0xd989, + 0xd995, 0xd9a2, 0xd9ae, 0xd9bb, 0xd9c8, 0xd9d4, 0xd9e1, 0xd9ed, 0xd9fa, 0xda06, 0xda13, 0xda1f, + 0xda2c, 0xda38, 0xda45, 0xda51, 0xda5e, 0xda6a, 0xda77, 0xda84, 0xda90, 0xda9d, 0xdaa9, 0xdab6, + 0xdac2, 0xdacf, 0xdadb, 0xdae7, 0xdaf4, 0xdb00, 0xdb0d, 0xdb19, 0xdb26, 0xdb32, 0xdb3f, 0xdb4b, + 0xdb58, 0xdb64, 0xdb71, 0xdb7d, 0xdb8a, 0xdb96, 0xdba2, 0xdbaf, 0xdbbb, 0xdbc8, 0xdbd4, 0xdbe1, + 0xdbed, 0xdbf9, 0xdc06, 0xdc12, 0xdc1f, 0xdc2b, 0xdc38, 0xdc44, 0xdc50, 0xdc5d, 0xdc69, 0xdc76, + 0xdc82, 0xdc8e, 0xdc9b, 0xdca7, 0xdcb3, 0xdcc0, 0xdccc, 0xdcd9, 0xdce5, 0xdcf1, 0xdcfe, 0xdd0a, + 0xdd16, 0xdd23, 0xdd2f, 0xdd3b, 0xdd48, 0xdd54, 0xdd60, 0xdd6d, 0xdd79, 0xdd85, 0xdd92, 0xdd9e, + 0xddaa, 0xddb7, 0xddc3, 0xddcf, 0xdddc, 0xdde8, 0xddf4, 0xde01, 0xde0d, 0xde19, 0xde25, 0xde32, + 0xde3e, 0xde4a, 0xde57, 0xde63, 0xde6f, 0xde7b, 0xde88, 0xde94, 0xdea0, 0xdeac, 0xdeb9, 0xdec5, + 0xded1, 0xdedd, 0xdeea, 0xdef6, 0xdf02, 0xdf0e, 0xdf1b, 0xdf27, 0xdf33, 0xdf3f, 0xdf4c, 0xdf58, + 0xdf64, 0xdf70, 0xdf7c, 0xdf89, 0xdf95, 0xdfa1, 0xdfad, 0xdfb9, 0xdfc6, 0xdfd2, 0xdfde, 0xdfea, + 0xdff6, 0xe003, 0xe00f, 0xe01b, 0xe027, 0xe033, 0xe03f, 0xe04c, 0xe058, 0xe064, 0xe070, 0xe07c, + 0xe088, 0xe094, 0xe0a1, 0xe0ad, 0xe0b9, 0xe0c5, 0xe0d1, 0xe0dd, 0xe0e9, 0xe0f5, 0xe102, 0xe10e, + 0xe11a, 0xe126, 0xe132, 0xe13e, 0xe14a, 0xe156, 0xe162, 0xe16e, 0xe17b, 0xe187, 0xe193, 0xe19f, + 0xe1ab, 0xe1b7, 0xe1c3, 0xe1cf, 0xe1db, 0xe1e7, 0xe1f3, 0xe1ff, 0xe20b, 0xe217, 0xe223, 0xe22f, + 0xe23c, 0xe248, 0xe254, 0xe260, 0xe26c, 0xe278, 0xe284, 0xe290, 0xe29c, 0xe2a8, 0xe2b4, 0xe2c0, + 0xe2cc, 0xe2d8, 0xe2e4, 0xe2f0, 0xe2fc, 0xe308, 0xe314, 0xe320, 0xe32c, 0xe338, 0xe344, 0xe350, + 0xe35c, 0xe368, 0xe374, 0xe380, 0xe38b, 0xe397, 0xe3a3, 0xe3af, 0xe3bb, 0xe3c7, 0xe3d3, 0xe3df, + 0xe3eb, 0xe3f7, 0xe403, 0xe40f, 0xe41b, 0xe427, 0xe433, 0xe43f, 0xe44a, 0xe456, 0xe462, 0xe46e, + 0xe47a, 0xe486, 0xe492, 0xe49e, 0xe4aa, 0xe4b6, 0xe4c1, 0xe4cd, 0xe4d9, 0xe4e5, 0xe4f1, 0xe4fd, + 0xe509, 0xe515, 0xe520, 0xe52c, 0xe538, 0xe544, 0xe550, 0xe55c, 0xe567, 0xe573, 0xe57f, 0xe58b, + 0xe597, 0xe5a3, 0xe5af, 0xe5ba, 0xe5c6, 0xe5d2, 0xe5de, 0xe5ea, 0xe5f5, 0xe601, 0xe60d, 0xe619, + 0xe625, 0xe630, 0xe63c, 0xe648, 0xe654, 0xe660, 0xe66b, 0xe677, 0xe683, 0xe68f, 0xe69a, 0xe6a6, + 0xe6b2, 0xe6be, 0xe6ca, 0xe6d5, 0xe6e1, 0xe6ed, 0xe6f9, 0xe704, 0xe710, 0xe71c, 0xe727, 0xe733, + 0xe73f, 0xe74b, 0xe756, 0xe762, 0xe76e, 0xe77a, 0xe785, 0xe791, 0xe79d, 0xe7a8, 0xe7b4, 0xe7c0, + 0xe7cb, 0xe7d7, 0xe7e3, 0xe7ef, 0xe7fa, 0xe806, 0xe812, 0xe81d, 0xe829, 0xe835, 0xe840, 0xe84c, + 0xe858, 0xe863, 0xe86f, 0xe87b, 0xe886, 0xe892, 0xe89e, 0xe8a9, 0xe8b5, 0xe8c0, 0xe8cc, 0xe8d8, + 0xe8e3, 0xe8ef, 0xe8fb, 0xe906, 0xe912, 0xe91d, 0xe929, 0xe935, 0xe940, 0xe94c, 0xe958, 0xe963, + 0xe96f, 0xe97a, 0xe986, 0xe991, 0xe99d, 0xe9a9, 0xe9b4, 0xe9c0, 0xe9cb, 0xe9d7, 0xe9e3, 0xe9ee, + 0xe9fa, 0xea05, 0xea11, 0xea1c, 0xea28, 0xea33, 0xea3f, 0xea4a, 0xea56, 0xea62, 0xea6d, 0xea79, + 0xea84, 0xea90, 0xea9b, 0xeaa7, 0xeab2, 0xeabe, 0xeac9, 0xead5, 0xeae0, 0xeaec, 0xeaf7, 0xeb03, + 0xeb0e, 0xeb1a, 0xeb25, 0xeb31, 0xeb3c, 0xeb48, 0xeb53, 0xeb5f, 0xeb6a, 0xeb76, 0xeb81, 0xeb8d, + 0xeb98, 0xeba3, 0xebaf, 0xebba, 0xebc6, 0xebd1, 0xebdd, 0xebe8, 0xebf4, 0xebff, 0xec0a, 0xec16, + 0xec21, 0xec2d, 0xec38, 0xec44, 0xec4f, 0xec5a, 0xec66, 0xec71, 0xec7d, 0xec88, 0xec93, 0xec9f, + 0xecaa, 0xecb6, 0xecc1, 0xeccc, 0xecd8, 0xece3, 0xecef, 0xecfa, 0xed05, 0xed11, 0xed1c, 0xed27, + 0xed33, 0xed3e, 0xed4a, 0xed55, 0xed60, 0xed6c, 0xed77, 0xed82, 0xed8e, 0xed99, 0xeda4, 0xedb0, + 0xedbb, 0xedc6, 0xedd2, 0xeddd, 0xede8, 0xedf4, 0xedff, 0xee0a, 0xee15, 0xee21, 0xee2c, 0xee37, + 0xee43, 0xee4e, 0xee59, 0xee65, 0xee70, 0xee7b, 0xee86, 0xee92, 0xee9d, 0xeea8, 0xeeb3, 0xeebf, + 0xeeca, 0xeed5, 0xeee1, 0xeeec, 0xeef7, 0xef02, 0xef0e, 0xef19, 0xef24, 0xef2f, 0xef3a, 0xef46, + 0xef51, 0xef5c, 0xef67, 0xef73, 0xef7e, 0xef89, 0xef94, 0xef9f, 0xefab, 0xefb6, 0xefc1, 0xefcc, + 0xefd7, 0xefe3, 0xefee, 0xeff9, 0xf004, 0xf00f, 0xf01b, 0xf026, 0xf031, 0xf03c, 0xf047, 0xf052, + 0xf05e, 0xf069, 0xf074, 0xf07f, 0xf08a, 0xf095, 0xf0a1, 0xf0ac, 0xf0b7, 0xf0c2, 0xf0cd, 0xf0d8, + 0xf0e3, 0xf0ef, 0xf0fa, 0xf105, 0xf110, 0xf11b, 0xf126, 0xf131, 0xf13c, 0xf147, 0xf153, 0xf15e, + 0xf169, 0xf174, 0xf17f, 0xf18a, 0xf195, 0xf1a0, 0xf1ab, 0xf1b6, 0xf1c2, 0xf1cd, 0xf1d8, 0xf1e3, + 0xf1ee, 0xf1f9, 0xf204, 0xf20f, 0xf21a, 0xf225, 0xf230, 0xf23b, 0xf246, 0xf251, 0xf25c, 0xf267, + 0xf272, 0xf27d, 0xf288, 0xf293, 0xf29f, 0xf2aa, 0xf2b5, 0xf2c0, 0xf2cb, 0xf2d6, 0xf2e1, 0xf2ec, + 0xf2f7, 0xf302, 0xf30d, 0xf318, 0xf323, 0xf32e, 0xf339, 0xf344, 0xf34f, 0xf35a, 0xf364, 0xf36f, + 0xf37a, 0xf385, 0xf390, 0xf39b, 0xf3a6, 0xf3b1, 0xf3bc, 0xf3c7, 0xf3d2, 0xf3dd, 0xf3e8, 0xf3f3, + 0xf3fe, 0xf409, 0xf414, 0xf41f, 0xf42a, 0xf435, 0xf43f, 0xf44a, 0xf455, 0xf460, 0xf46b, 0xf476, + 0xf481, 0xf48c, 0xf497, 0xf4a2, 0xf4ad, 0xf4b7, 0xf4c2, 0xf4cd, 0xf4d8, 0xf4e3, 0xf4ee, 0xf4f9, + 0xf504, 0xf50f, 0xf519, 0xf524, 0xf52f, 0xf53a, 0xf545, 0xf550, 0xf55b, 0xf565, 0xf570, 0xf57b, + 0xf586, 0xf591, 0xf59c, 0xf5a6, 0xf5b1, 0xf5bc, 0xf5c7, 0xf5d2, 0xf5dd, 0xf5e7, 0xf5f2, 0xf5fd, + 0xf608, 0xf613, 0xf61d, 0xf628, 0xf633, 0xf63e, 0xf649, 0xf653, 0xf65e, 0xf669, 0xf674, 0xf67f, + 0xf689, 0xf694, 0xf69f, 0xf6aa, 0xf6b4, 0xf6bf, 0xf6ca, 0xf6d5, 0xf6e0, 0xf6ea, 0xf6f5, 0xf700, + 0xf70b, 0xf715, 0xf720, 0xf72b, 0xf736, 0xf740, 0xf74b, 0xf756, 0xf760, 0xf76b, 0xf776, 0xf781, + 0xf78b, 0xf796, 0xf7a1, 0xf7ab, 0xf7b6, 0xf7c1, 0xf7cc, 0xf7d6, 0xf7e1, 0xf7ec, 0xf7f6, 0xf801, + 0xf80c, 0xf816, 0xf821, 0xf82c, 0xf836, 0xf841, 0xf84c, 0xf856, 0xf861, 0xf86c, 0xf876, 0xf881, + 0xf88c, 0xf896, 0xf8a1, 0xf8ac, 0xf8b6, 0xf8c1, 0xf8cc, 0xf8d6, 0xf8e1, 0xf8ec, 0xf8f6, 0xf901, + 0xf90b, 0xf916, 0xf921, 0xf92b, 0xf936, 0xf941, 0xf94b, 0xf956, 0xf960, 0xf96b, 0xf976, 0xf980, + 0xf98b, 0xf995, 0xf9a0, 0xf9aa, 0xf9b5, 0xf9c0, 0xf9ca, 0xf9d5, 0xf9df, 0xf9ea, 0xf9f4, 0xf9ff, + 0xfa0a, 0xfa14, 0xfa1f, 0xfa29, 0xfa34, 0xfa3e, 0xfa49, 0xfa53, 0xfa5e, 0xfa69, 0xfa73, 0xfa7e, + 0xfa88, 0xfa93, 0xfa9d, 0xfaa8, 0xfab2, 0xfabd, 0xfac7, 0xfad2, 0xfadc, 0xfae7, 0xfaf1, 0xfafc, + 0xfb06, 0xfb11, 0xfb1b, 0xfb26, 0xfb30, 0xfb3b, 0xfb45, 0xfb50, 0xfb5a, 0xfb65, 0xfb6f, 0xfb7a, + 0xfb84, 0xfb8f, 0xfb99, 0xfba4, 0xfbae, 0xfbb8, 0xfbc3, 0xfbcd, 0xfbd8, 0xfbe2, 0xfbed, 0xfbf7, + 0xfc02, 0xfc0c, 0xfc16, 0xfc21, 0xfc2b, 0xfc36, 0xfc40, 0xfc4b, 0xfc55, 0xfc5f, 0xfc6a, 0xfc74, + 0xfc7f, 0xfc89, 0xfc93, 0xfc9e, 0xfca8, 0xfcb3, 0xfcbd, 0xfcc7, 0xfcd2, 0xfcdc, 0xfce7, 0xfcf1, + 0xfcfb, 0xfd06, 0xfd10, 0xfd1a, 0xfd25, 0xfd2f, 0xfd3a, 0xfd44, 0xfd4e, 0xfd59, 0xfd63, 0xfd6d, + 0xfd78, 0xfd82, 0xfd8c, 0xfd97, 0xfda1, 0xfdab, 0xfdb6, 0xfdc0, 0xfdca, 0xfdd5, 0xfddf, 0xfde9, + 0xfdf4, 0xfdfe, 0xfe08, 0xfe13, 0xfe1d, 0xfe27, 0xfe32, 0xfe3c, 0xfe46, 0xfe50, 0xfe5b, 0xfe65, + 0xfe6f, 0xfe7a, 0xfe84, 0xfe8e, 0xfe98, 0xfea3, 0xfead, 0xfeb7, 0xfec1, 0xfecc, 0xfed6, 0xfee0, + 0xfeeb, 0xfef5, 0xfeff, 0xff09, 0xff14, 0xff1e, 0xff28, 0xff32, 0xff3c, 0xff47, 0xff51, 0xff5b, + 0xff65, 0xff70, 0xff7a, 0xff84, 0xff8e, 0xff98, 0xffa3, 0xffad, 0xffb7, 0xffc1, 0xffcc, 0xffd6, + 0xffe0, 0xffea, 0xfff4, 0xffff}; + +// max value is pi/4 +constexpr double SCALING_FACTOR = 4. / M_PI * 0xFFFF; + +inline double atan2_lookup(double y, double x) +{ + if (std::abs(x) < std::numeric_limits::epsilon()) + { + if (y >= 0.) + { + return M_PI / 2.; + } + else + { + return -M_PI / 2.; + } + } + + unsigned octant = 0; + + if (x < 0.) + { + octant = 1; + x = -x; + } + if (y < 0.) + { + octant |= 2; + y = -y; + } + + double t = y / x; + if (t > 1.0) + { + octant |= 4; + t = 1.0 / t; + } + + double angle = atan_table[(unsigned)(t * 4095)] / SCALING_FACTOR; + + switch (octant) + { + case 0: + break; + case 1: + angle = M_PI - angle; + break; + case 2: + angle = -angle; + break; + case 3: + angle = -M_PI + angle; + break; + case 4: + angle = M_PI / 2.0 - angle; + break; + case 5: + angle = M_PI / 2.0 + angle; + break; + case 6: + angle = -M_PI / 2.0 + angle; + break; + case 7: + angle = -M_PI / 2.0 - angle; + break; + } + return angle; +} + +#endif // TRIGONOMETRY_TABLE_HPP diff --git a/util/xml_renderer.hpp b/util/xml_renderer.hpp new file mode 100644 index 000000000..bbf2287e1 --- /dev/null +++ b/util/xml_renderer.hpp @@ -0,0 +1,140 @@ +/* + +Copyright (c) 2014, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef XML_RENDERER_HPP +#define XML_RENDERER_HPP + +#include "cast.hpp" + +#include + +namespace JSON +{ + +struct XMLToArrayRenderer : mapbox::util::static_visitor<> +{ + explicit XMLToArrayRenderer(std::vector &_out) : out(_out) {} + + void operator()(const String &string) const + { + out.push_back('\"'); + out.insert(out.end(), string.value.begin(), string.value.end()); + out.push_back('\"'); + } + + void operator()(const Number &number) const + { + const std::string number_string = cast::double_fixed_to_string(number.value); + out.insert(out.end(), number_string.begin(), number_string.end()); + } + + void operator()(const Object &object) const + { + auto iterator = object.values.begin(); + while (iterator != object.values.end()) + { + if (iterator->first.at(0) != '_') + { + out.push_back('<'); + out.insert(out.end(), (*iterator).first.begin(), (*iterator).first.end()); + } + else + { + out.push_back(' '); + out.insert(out.end(), ++(*iterator).first.begin(), (*iterator).first.end()); + out.push_back('='); + } + mapbox::util::apply_visitor(XMLToArrayRenderer(out), (*iterator).second); + if (iterator->first.at(0) != '_') + { + out.push_back('/'); + out.push_back('>'); + } + ++iterator; + } + } + + void operator()(const Array &array) const + { + std::vector::const_iterator iterator; + iterator = array.values.begin(); + while (iterator != array.values.end()) + { + mapbox::util::apply_visitor(XMLToArrayRenderer(out), *iterator); + ++iterator; + } + } + + void operator()(const True &) const + { + const std::string temp("true"); + out.insert(out.end(), temp.begin(), temp.end()); + } + + void operator()(const False &) const + { + const std::string temp("false"); + out.insert(out.end(), temp.begin(), temp.end()); + } + + void operator()(const Null &) const + { + const std::string temp("null"); + out.insert(out.end(), temp.begin(), temp.end()); + } + + private: + std::vector &out; +}; + +template inline void xml_render(std::vector &out, const JSONObject &object) +{ + Value value = object; + mapbox::util::apply_visitor(XMLToArrayRenderer(out), value); +} + +template inline void gpx_render(std::vector &out, const JSONObject &object) +{ + // add header + + const std::string header{ + "Data (c) OpenStreetMap contributors (ODbL)"}; + out.insert(out.end(), header.begin(), header.end()); + + xml_render(out, object); + + const std::string footer{""}; + out.insert(out.end(), footer.begin(), footer.end()); +} +} // namespace JSON + +#endif // XML_RENDERER_HPP