diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index cd45be71c..f4cb0c47a 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -143,6 +143,8 @@ class BaseDataFacade virtual std::size_t GetCoreSize() const = 0; virtual std::string GetTimestamp() const = 0; + + virtual bool GetUTurnsDefault() const = 0; }; } } diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 3c0c84d7c..1189e7dd4 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -9,6 +9,7 @@ #include "engine/geospatial_query.hpp" #include "extractor/original_edge_data.hpp" +#include "extractor/profile_properties.hpp" #include "extractor/query_node.hpp" #include "contractor/query_edge.hpp" #include "util/shared_memory_vector_wrapper.hpp" @@ -79,6 +80,7 @@ class InternalDataFacade final : public BaseDataFacade util::ShM::vector m_segment_weights; util::ShM::vector m_datasource_list; util::ShM::vector m_datasource_names; + extractor::ProfileProperties m_profile_properties; boost::thread_specific_ptr m_static_rtree; boost::thread_specific_ptr m_geospatial_query; @@ -86,6 +88,17 @@ class InternalDataFacade final : public BaseDataFacade boost::filesystem::path file_index_path; util::RangeTable<16, false> m_name_table; + void LoadProfileProperties(const boost::filesystem::path &properties_path) + { + boost::filesystem::ifstream in_stream(properties_path); + if (!in_stream) + { + throw util::exception("Could not open " + properties_path.string() + " for reading."); + } + + in_stream.read(reinterpret_cast(&m_profile_properties), sizeof(m_profile_properties)); + } + void LoadTimestamp(const boost::filesystem::path ×tamp_path) { if (boost::filesystem::exists(timestamp_path)) @@ -320,6 +333,9 @@ class InternalDataFacade final : public BaseDataFacade util::SimpleLogger().Write() << "loading timestamp"; LoadTimestamp(file_for("timestamp")); + util::SimpleLogger().Write() << "loading profile properties"; + LoadProfileProperties(file_for("properties")); + util::SimpleLogger().Write() << "loading street names"; LoadStreetNames(file_for("namesdata")); } @@ -662,6 +678,8 @@ class InternalDataFacade final : public BaseDataFacade } std::string GetTimestamp() const override final { return m_timestamp; } + + bool GetUTurnsDefault() const override final { return m_profile_properties.allow_u_turn_at_via; } }; } } diff --git a/include/engine/datafacade/shared_datafacade.hpp b/include/engine/datafacade/shared_datafacade.hpp index 6838c63ef..2d2611763 100644 --- a/include/engine/datafacade/shared_datafacade.hpp +++ b/include/engine/datafacade/shared_datafacade.hpp @@ -8,6 +8,7 @@ #include "storage/shared_memory.hpp" #include "extractor/guidance/turn_instruction.hpp" +#include "extractor/profile_properties.hpp" #include "engine/geospatial_query.hpp" #include "util/range_table.hpp" @@ -68,6 +69,7 @@ class SharedDataFacade final : public BaseDataFacade std::unique_ptr m_layout_memory; std::unique_ptr m_large_memory; std::string m_timestamp; + extractor::ProfileProperties* m_profile_properties; std::shared_ptr::vector> m_coordinate_list; util::ShM::vector m_via_node_list; @@ -98,6 +100,12 @@ class SharedDataFacade final : public BaseDataFacade util::SimpleLogger().Write() << "set checksum: " << m_check_sum; } + void LoadProfileProperties() + { + m_profile_properties = + data_layout->GetBlockPtr(shared_memory, storage::SharedDataLayout::PROPERTIES); + } + void LoadTimestamp() { auto timestamp_ptr = @@ -343,6 +351,7 @@ class SharedDataFacade final : public BaseDataFacade LoadViaNodeList(); LoadNames(); LoadCoreInformation(); + LoadProfileProperties(); util::SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size(); @@ -703,6 +712,8 @@ class SharedDataFacade final : public BaseDataFacade } std::string GetTimestamp() const override final { return m_timestamp; } + + bool GetUTurnsDefault() const override final { return m_profile_properties->allow_u_turn_at_via; } }; } } diff --git a/include/engine/routing_algorithms/shortest_path.hpp b/include/engine/routing_algorithms/shortest_path.hpp index 2d6dfaeb6..a03f082f1 100644 --- a/include/engine/routing_algorithms/shortest_path.hpp +++ b/include/engine/routing_algorithms/shortest_path.hpp @@ -237,8 +237,6 @@ class ShortestPathRouting final } } - static const constexpr bool UTURN_DEFAULT = false; - void operator()(const std::vector &phantom_nodes_vector, const boost::optional uturns, InternalRouteResult &raw_route_data) const @@ -268,7 +266,7 @@ class ShortestPathRouting final std::vector total_packed_path_to_reverse; std::vector packed_leg_to_reverse_begin; - const bool allow_u_turn_at_via = uturns ? *uturns : UTURN_DEFAULT; + const bool allow_u_turn_at_via = uturns ? *uturns : super::facade->GetUTurnsDefault(); std::size_t current_leg = 0; // this implements a dynamic program that finds the shortest route through diff --git a/include/storage/shared_datatype.hpp b/include/storage/shared_datatype.hpp index 4be19df4d..ec1033a0d 100644 --- a/include/storage/shared_datatype.hpp +++ b/include/storage/shared_datatype.hpp @@ -41,6 +41,7 @@ struct SharedDataLayout DATASOURCE_NAME_DATA, DATASOURCE_NAME_OFFSETS, DATASOURCE_NAME_LENGTHS, + PROPERTIES, NUM_BLOCKS }; diff --git a/include/util/routed_options.hpp b/include/util/routed_options.hpp index 2ea65f82e..3a91b8d55 100644 --- a/include/util/routed_options.hpp +++ b/include/util/routed_options.hpp @@ -53,10 +53,12 @@ populate_base_path(std::unordered_map &ser BOOST_ASSERT(server_paths.find("namesdata") != server_paths.end()); server_paths["timestamp"] = base_string + ".timestamp"; BOOST_ASSERT(server_paths.find("timestamp") != server_paths.end()); + server_paths["properties"] = base_string + ".properties"; + BOOST_ASSERT(server_paths.find("properties") != server_paths.end()); server_paths["datasource_indexes"] = base_string + ".datasource_indexes"; - BOOST_ASSERT(server_paths.find("timestamp") != server_paths.end()); + BOOST_ASSERT(server_paths.find("datasource_indexes") != server_paths.end()); server_paths["datasource_names"] = base_string + ".datasource_names"; - BOOST_ASSERT(server_paths.find("timestamp") != server_paths.end()); + BOOST_ASSERT(server_paths.find("datasource_names") != server_paths.end()); } // check if files are give and whether they exist at all diff --git a/src/extractor/scripting_environment.cpp b/src/extractor/scripting_environment.cpp index b2a54be16..09f524c8f 100644 --- a/src/extractor/scripting_environment.cpp +++ b/src/extractor/scripting_environment.cpp @@ -157,8 +157,8 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context) .def_readonly("datum", &RasterDatum::datum) .def("invalid_data", &RasterDatum::get_invalid)]; - luabind::globals(context.state)["properties"] = context.properties; - luabind::globals(context.state)["sources"] = context.sources; + luabind::globals(context.state)["properties"] = &context.properties; + luabind::globals(context.state)["sources"] = &context.sources; if (0 != luaL_dofile(context.state, file_name.c_str())) { diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 053a705db..184609362 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -2,6 +2,7 @@ #include "util/range_table.hpp" #include "contractor/query_edge.hpp" #include "extractor/query_node.hpp" +#include "extractor/profile_properties.hpp" #include "extractor/compressed_edge_container.hpp" #include "util/shared_memory_vector_wrapper.hpp" #include "util/static_graph.hpp" @@ -148,6 +149,10 @@ int Storage::Run() BOOST_ASSERT(paths.end() != paths_iterator); BOOST_ASSERT(!paths_iterator->second.empty()); const boost::filesystem::path ×tamp_path = paths_iterator->second; + paths_iterator = paths.find("properties"); + BOOST_ASSERT(paths.end() != paths_iterator); + BOOST_ASSERT(!paths_iterator->second.empty()); + const boost::filesystem::path &properties_path = paths_iterator->second; paths_iterator = paths.find("ramindex"); BOOST_ASSERT(paths.end() != paths_iterator); BOOST_ASSERT(!paths_iterator->second.empty()); @@ -285,6 +290,9 @@ int Storage::Run() tree_node_file.read((char *)&tree_size, sizeof(uint32_t)); shared_layout_ptr->SetBlockSize(SharedDataLayout::R_SEARCH_TREE, tree_size); + // load profile properties + shared_layout_ptr->SetBlockSize(SharedDataLayout::PROPERTIES, 1); + // load timestamp size std::string m_timestamp; if (boost::filesystem::exists(timestamp_path)) @@ -605,6 +613,15 @@ int Storage::Run() } hsgr_input_stream.close(); + // load profile properties + auto profile_properties_ptr = shared_layout_ptr->GetBlockPtr(shared_memory_ptr, SharedDataLayout::PROPERTIES); + boost::filesystem::ifstream profile_properties_stream(properties_path); + if (!profile_properties_stream) + { + util::exception("Could not open " + properties_path.string() + " for reading!"); + } + profile_properties_stream.read(reinterpret_cast(profile_properties_ptr), sizeof(extractor::ProfileProperties)); + // acquire lock SharedMemory *data_type_memory = makeSharedMemory(CURRENT_REGIONS, sizeof(SharedDataTimestamp), true, false); diff --git a/src/tools/store.cpp b/src/tools/store.cpp index b2a589e58..31e01cf2c 100644 --- a/src/tools/store.cpp +++ b/src/tools/store.cpp @@ -44,7 +44,9 @@ bool generateDataStoreOptions(const int argc, const char *argv[], storage::DataP ".datasource_names file")( "datasource_indexes", boost::program_options::value(&paths["datasource_indexes"]), - ".datasource_indexes file"); + ".datasource_indexes file")( + "properties", boost::program_options::value(&paths["properties"]), + ".properties file"); // hidden options, will be allowed on command line but will not be shown to the user boost::program_options::options_description hidden_options("Hidden options"); @@ -151,6 +153,12 @@ bool generateDataStoreOptions(const int argc, const char *argv[], storage::DataP path_iterator->second = base_string + ".timestamp"; } + path_iterator = paths.find("properties"); + if (path_iterator != paths.end()) + { + path_iterator->second = base_string + ".properties"; + } + path_iterator = paths.find("datasource_indexes"); if (path_iterator != paths.end()) { @@ -219,6 +227,13 @@ bool generateDataStoreOptions(const int argc, const char *argv[], storage::DataP throw util::exception("valid .timestamp file must be specified"); } + path_iterator = paths.find("properties"); + if (path_iterator == paths.end() || path_iterator->second.string().empty() || + !boost::filesystem::is_regular_file(path_iterator->second)) + { + throw util::exception("valid .properties file must be specified"); + } + return true; }