2015-01-27 06:35:29 -05:00
|
|
|
#ifndef INTERNAL_DATAFACADE_HPP
|
|
|
|
#define INTERNAL_DATAFACADE_HPP
|
|
|
|
|
|
|
|
// implements all data storage when shared memory is _NOT_ used
|
|
|
|
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "engine/datafacade/datafacade_base.hpp"
|
|
|
|
|
2016-03-01 16:30:31 -05:00
|
|
|
#include "extractor/guidance/turn_instruction.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "util/guidance/bearing_class.hpp"
|
|
|
|
#include "util/guidance/entry_class.hpp"
|
2016-03-01 16:30:31 -05:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "extractor/compressed_edge_container.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "extractor/original_edge_data.hpp"
|
2016-03-21 18:34:59 -04:00
|
|
|
#include "extractor/profile_properties.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "extractor/query_node.hpp"
|
2016-10-18 14:21:41 -04:00
|
|
|
#include "storage/io.hpp"
|
2016-05-10 02:37:45 -04:00
|
|
|
#include "storage/storage_config.hpp"
|
2016-05-27 15:05:04 -04:00
|
|
|
#include "engine/geospatial_query.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "util/graph_loader.hpp"
|
2016-08-17 03:49:19 -04:00
|
|
|
#include "util/guidance/turn_bearing.hpp"
|
2016-06-15 08:38:24 -04:00
|
|
|
#include "util/guidance/turn_lanes.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "util/io.hpp"
|
2016-06-02 08:43:27 -04:00
|
|
|
#include "util/packed_vector.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "util/range_table.hpp"
|
|
|
|
#include "util/rectangle.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "util/shared_memory_vector_wrapper.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "util/simple_logger.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "util/static_graph.hpp"
|
|
|
|
#include "util/static_rtree.hpp"
|
2016-05-10 02:37:45 -04:00
|
|
|
#include "util/typedefs.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
|
|
|
|
#include "osrm/coordinate.hpp"
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-02-05 08:58:06 -05:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdlib>
|
2015-12-03 14:04:23 -05:00
|
|
|
|
2016-02-05 08:58:06 -05:00
|
|
|
#include <algorithm>
|
|
|
|
#include <fstream>
|
|
|
|
#include <ios>
|
2015-02-26 04:11:33 -05:00
|
|
|
#include <limits>
|
2016-02-05 08:58:06 -05:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
#include <boost/filesystem/fstream.hpp>
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <boost/thread/tss.hpp>
|
2015-02-26 04:11:33 -05:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace datafacade
|
|
|
|
{
|
|
|
|
|
2016-01-28 10:28:44 -05:00
|
|
|
class InternalDataFacade final : public BaseDataFacade
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
2016-01-28 10:28:44 -05:00
|
|
|
using super = BaseDataFacade;
|
2016-01-05 10:51:13 -05:00
|
|
|
using QueryGraph = util::StaticGraph<typename super::EdgeData>;
|
2016-05-03 05:48:33 -04:00
|
|
|
using InputEdge = QueryGraph::InputEdge;
|
|
|
|
using RTreeLeaf = super::RTreeLeaf;
|
2016-01-07 19:31:57 -05:00
|
|
|
using InternalRTree =
|
2016-02-23 15:23:13 -05:00
|
|
|
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, false>::vector, false>;
|
2016-01-28 10:28:44 -05:00
|
|
|
using InternalGeospatialQuery = GeospatialQuery<InternalRTree, BaseDataFacade>;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
|
|
|
InternalDataFacade() {}
|
|
|
|
|
|
|
|
unsigned m_check_sum;
|
2015-12-03 14:04:23 -05:00
|
|
|
std::unique_ptr<QueryGraph> m_query_graph;
|
2015-01-27 06:35:29 -05:00
|
|
|
std::string m_timestamp;
|
|
|
|
|
2016-05-06 20:43:37 -04:00
|
|
|
util::ShM<util::Coordinate, false>::vector m_coordinate_list;
|
2016-05-27 13:30:30 -04:00
|
|
|
util::PackedVector<OSMNodeID, false> m_osmnodeid_list;
|
2016-07-22 12:23:54 -04:00
|
|
|
util::ShM<GeometryID, false>::vector m_via_geometry_list;
|
2016-01-05 10:51:13 -05:00
|
|
|
util::ShM<unsigned, false>::vector m_name_ID_list;
|
2016-03-01 16:30:31 -05:00
|
|
|
util::ShM<extractor::guidance::TurnInstruction, false>::vector m_turn_instruction_list;
|
2016-06-15 08:38:24 -04:00
|
|
|
util::ShM<LaneDataID, false>::vector m_lane_data_id;
|
2016-10-04 15:28:13 -04:00
|
|
|
util::ShM<util::guidance::LaneTupleIdPair, false>::vector m_lane_tuple_id_pairs;
|
2016-01-05 10:51:13 -05:00
|
|
|
util::ShM<extractor::TravelMode, false>::vector m_travel_mode_list;
|
|
|
|
util::ShM<char, false>::vector m_names_char_list;
|
|
|
|
util::ShM<unsigned, false>::vector m_geometry_indices;
|
2016-10-07 00:06:33 -04:00
|
|
|
util::ShM<NodeID, false>::vector m_geometry_node_list;
|
|
|
|
util::ShM<EdgeWeight, false>::vector m_geometry_fwd_weight_list;
|
|
|
|
util::ShM<EdgeWeight, false>::vector m_geometry_rev_weight_list;
|
2016-01-05 10:51:13 -05:00
|
|
|
util::ShM<bool, false>::vector m_is_core_node;
|
2016-03-15 02:03:19 -04:00
|
|
|
util::ShM<uint8_t, false>::vector m_datasource_list;
|
|
|
|
util::ShM<std::string, false>::vector m_datasource_names;
|
2016-06-21 04:41:08 -04:00
|
|
|
util::ShM<std::uint32_t, false>::vector m_lane_description_offsets;
|
|
|
|
util::ShM<extractor::guidance::TurnLaneType::Mask, false>::vector m_lane_description_masks;
|
2016-03-21 18:34:59 -04:00
|
|
|
extractor::ProfileProperties m_profile_properties;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-05-06 19:53:11 -04:00
|
|
|
std::unique_ptr<InternalRTree> m_static_rtree;
|
|
|
|
std::unique_ptr<InternalGeospatialQuery> m_geospatial_query;
|
2015-01-27 06:35:29 -05:00
|
|
|
boost::filesystem::path ram_index_path;
|
|
|
|
boost::filesystem::path file_index_path;
|
2016-01-05 10:51:13 -05:00
|
|
|
util::RangeTable<16, false> m_name_table;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
// bearing classes by node based node
|
|
|
|
util::ShM<BearingClassID, false>::vector m_bearing_class_id_table;
|
|
|
|
// entry class IDs by edge based egde
|
|
|
|
util::ShM<EntryClassID, false>::vector m_entry_class_id_list;
|
2016-08-17 03:49:19 -04:00
|
|
|
// bearings pre/post turn
|
|
|
|
util::ShM<util::guidance::TurnBearing, false>::vector m_pre_turn_bearing;
|
|
|
|
util::ShM<util::guidance::TurnBearing, false>::vector m_post_turn_bearing;
|
2016-04-26 07:27:40 -04:00
|
|
|
// the look-up table for entry classes. An entry class lists the possibility of entry for all
|
|
|
|
// available turns. For every turn, there is an associated entry class.
|
|
|
|
util::ShM<util::guidance::EntryClass, false>::vector m_entry_class_table;
|
|
|
|
// the look-up table for distinct bearing classes. A bearing class lists the available bearings
|
|
|
|
// at an intersection
|
2016-05-10 02:37:45 -04:00
|
|
|
util::RangeTable<16, false> m_bearing_ranges_table;
|
|
|
|
util::ShM<DiscreteBearing, false>::vector m_bearing_values_table;
|
2016-04-26 07:27:40 -04:00
|
|
|
|
2016-03-21 18:34:59 -04:00
|
|
|
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.");
|
|
|
|
}
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto properties_size = storage::io::readPropertiesCount();
|
|
|
|
storage::io::readProperties(in_stream, &m_profile_properties, properties_size);
|
2016-03-21 18:34:59 -04:00
|
|
|
}
|
|
|
|
|
2016-10-04 15:28:13 -04:00
|
|
|
void LoadLaneTupleIdPairs(const boost::filesystem::path &lane_data_path)
|
2016-06-15 08:38:24 -04:00
|
|
|
{
|
|
|
|
boost::filesystem::ifstream in_stream(lane_data_path);
|
|
|
|
if (!in_stream)
|
|
|
|
{
|
|
|
|
throw util::exception("Could not open " + lane_data_path.string() + " for reading.");
|
|
|
|
}
|
|
|
|
std::uint64_t size;
|
|
|
|
in_stream.read(reinterpret_cast<char *>(&size), sizeof(size));
|
2016-10-04 15:28:13 -04:00
|
|
|
m_lane_tuple_id_pairs.resize(size);
|
|
|
|
in_stream.read(reinterpret_cast<char *>(&m_lane_tuple_id_pairs[0]),
|
|
|
|
sizeof(m_lane_tuple_id_pairs) * size);
|
2016-06-15 08:38:24 -04:00
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
void LoadTimestamp(const boost::filesystem::path ×tamp_path)
|
|
|
|
{
|
2016-03-23 11:58:47 -04:00
|
|
|
util::SimpleLogger().Write() << "Loading Timestamp";
|
2016-10-18 14:21:41 -04:00
|
|
|
|
2016-03-23 11:58:47 -04:00
|
|
|
boost::filesystem::ifstream timestamp_stream(timestamp_path);
|
|
|
|
if (!timestamp_stream)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-03-23 11:58:47 -04:00
|
|
|
throw util::exception("Could not open " + timestamp_path.string() + " for reading.");
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
2016-10-18 14:21:41 -04:00
|
|
|
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto timestamp_size = storage::io::readNumberOfBytes(timestamp_stream);
|
2016-10-19 14:55:35 -04:00
|
|
|
m_timestamp.resize(timestamp_size);
|
|
|
|
storage::io::readTimestamp(timestamp_stream, &m_timestamp.front(), timestamp_size);
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoadGraph(const boost::filesystem::path &hsgr_path)
|
|
|
|
{
|
2016-10-17 19:32:52 -04:00
|
|
|
boost::filesystem::ifstream hsgr_input_stream(hsgr_path);
|
|
|
|
if (!hsgr_input_stream)
|
|
|
|
{
|
|
|
|
throw util::exception("Could not open " + hsgr_path.string() + " for reading.");
|
|
|
|
}
|
|
|
|
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto header = storage::io::readHSGRHeader(hsgr_input_stream);
|
2016-10-17 19:32:52 -04:00
|
|
|
m_check_sum = header.checksum;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-10-17 19:32:52 -04:00
|
|
|
util::ShM<QueryGraph::NodeArrayEntry, false>::vector node_list(header.number_of_nodes);
|
|
|
|
util::ShM<QueryGraph::EdgeArrayEntry, false>::vector edge_list(header.number_of_edges);
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-10-17 19:32:52 -04:00
|
|
|
storage::io::readHSGR(hsgr_input_stream,
|
|
|
|
node_list.data(),
|
|
|
|
header.number_of_nodes,
|
|
|
|
edge_list.data(),
|
|
|
|
header.number_of_edges);
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-12-03 14:04:23 -05:00
|
|
|
m_query_graph = std::unique_ptr<QueryGraph>(new QueryGraph(node_list, edge_list));
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "Data checksum is " << m_check_sum;
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-10-18 15:00:02 -04:00
|
|
|
void LoadNodeAndEdgeInformation(const boost::filesystem::path &nodes_file_path,
|
|
|
|
const boost::filesystem::path &edges_file_path)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-10-18 15:00:02 -04:00
|
|
|
boost::filesystem::ifstream nodes_input_stream(nodes_file_path, std::ios::binary);
|
|
|
|
if (!nodes_input_stream)
|
|
|
|
{
|
|
|
|
throw util::exception("Could not open " + nodes_file_path.string() + " for reading.");
|
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto number_of_coordinates = storage::io::readElementCount(nodes_input_stream);
|
2016-05-06 20:43:37 -04:00
|
|
|
m_coordinate_list.resize(number_of_coordinates);
|
2016-05-23 20:13:32 -04:00
|
|
|
m_osmnodeid_list.reserve(number_of_coordinates);
|
2016-10-21 18:24:55 -04:00
|
|
|
storage::io::readNodes(
|
2016-10-18 15:00:02 -04:00
|
|
|
nodes_input_stream, m_coordinate_list.data(), m_osmnodeid_list, number_of_coordinates);
|
|
|
|
|
|
|
|
boost::filesystem::ifstream edges_input_stream(edges_file_path, std::ios::binary);
|
|
|
|
if (!edges_input_stream)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-10-18 15:00:02 -04:00
|
|
|
throw util::exception("Could not open " + edges_file_path.string() + " for reading.");
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto number_of_edges = storage::io::readElementCount(edges_input_stream);
|
2016-07-22 12:23:54 -04:00
|
|
|
m_via_geometry_list.resize(number_of_edges);
|
2015-01-27 06:35:29 -05:00
|
|
|
m_name_ID_list.resize(number_of_edges);
|
|
|
|
m_turn_instruction_list.resize(number_of_edges);
|
2016-06-15 08:38:24 -04:00
|
|
|
m_lane_data_id.resize(number_of_edges);
|
2015-01-27 06:35:29 -05:00
|
|
|
m_travel_mode_list.resize(number_of_edges);
|
2016-04-26 07:27:40 -04:00
|
|
|
m_entry_class_id_list.resize(number_of_edges);
|
2016-08-17 03:49:19 -04:00
|
|
|
m_pre_turn_bearing.resize(number_of_edges);
|
|
|
|
m_post_turn_bearing.resize(number_of_edges);
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-10-21 18:24:55 -04:00
|
|
|
storage::io::readEdges(edges_input_stream,
|
|
|
|
m_via_geometry_list.data(),
|
|
|
|
m_name_ID_list.data(),
|
|
|
|
m_turn_instruction_list.data(),
|
|
|
|
m_lane_data_id.data(),
|
|
|
|
m_travel_mode_list.data(),
|
|
|
|
m_entry_class_id_list.data(),
|
|
|
|
m_pre_turn_bearing.data(),
|
|
|
|
m_post_turn_bearing.data(),
|
|
|
|
number_of_edges);
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2015-08-09 12:31:11 -04:00
|
|
|
void LoadCoreInformation(const boost::filesystem::path &core_data_file)
|
|
|
|
{
|
|
|
|
std::ifstream core_stream(core_data_file.string().c_str(), std::ios::binary);
|
|
|
|
unsigned number_of_markers;
|
|
|
|
core_stream.read((char *)&number_of_markers, sizeof(unsigned));
|
|
|
|
|
|
|
|
std::vector<char> unpacked_core_markers(number_of_markers);
|
2015-09-08 19:57:29 -04:00
|
|
|
core_stream.read((char *)unpacked_core_markers.data(), sizeof(char) * number_of_markers);
|
2015-08-09 12:31:11 -04:00
|
|
|
|
2015-08-19 05:44:49 -04:00
|
|
|
// in this case we have nothing to do
|
|
|
|
if (number_of_markers <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-09 12:31:11 -04:00
|
|
|
m_is_core_node.resize(number_of_markers);
|
|
|
|
for (auto i = 0u; i < number_of_markers; ++i)
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(unpacked_core_markers[i] == 0 || unpacked_core_markers[i] == 1);
|
|
|
|
m_is_core_node[i] = unpacked_core_markers[i] == 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
void LoadGeometries(const boost::filesystem::path &geometry_file)
|
|
|
|
{
|
|
|
|
std::ifstream geometry_stream(geometry_file.string().c_str(), std::ios::binary);
|
|
|
|
unsigned number_of_indices = 0;
|
|
|
|
unsigned number_of_compressed_geometries = 0;
|
|
|
|
|
|
|
|
geometry_stream.read((char *)&number_of_indices, sizeof(unsigned));
|
|
|
|
|
|
|
|
m_geometry_indices.resize(number_of_indices);
|
|
|
|
if (number_of_indices > 0)
|
|
|
|
{
|
|
|
|
geometry_stream.read((char *)&(m_geometry_indices[0]),
|
|
|
|
number_of_indices * sizeof(unsigned));
|
|
|
|
}
|
|
|
|
|
|
|
|
geometry_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned));
|
|
|
|
|
|
|
|
BOOST_ASSERT(m_geometry_indices.back() == number_of_compressed_geometries);
|
2016-10-07 00:06:33 -04:00
|
|
|
m_geometry_node_list.resize(number_of_compressed_geometries);
|
|
|
|
m_geometry_fwd_weight_list.resize(number_of_compressed_geometries);
|
|
|
|
m_geometry_rev_weight_list.resize(number_of_compressed_geometries);
|
2015-01-27 06:35:29 -05:00
|
|
|
|
|
|
|
if (number_of_compressed_geometries > 0)
|
|
|
|
{
|
2016-10-07 00:06:33 -04:00
|
|
|
geometry_stream.read((char *)&(m_geometry_node_list[0]),
|
2016-10-19 20:11:36 -04:00
|
|
|
number_of_compressed_geometries * sizeof(NodeID));
|
2016-10-07 00:06:33 -04:00
|
|
|
|
|
|
|
geometry_stream.read((char *)&(m_geometry_fwd_weight_list[0]),
|
2016-10-19 20:11:36 -04:00
|
|
|
number_of_compressed_geometries * sizeof(EdgeWeight));
|
2016-10-07 00:06:33 -04:00
|
|
|
|
|
|
|
geometry_stream.read((char *)&(m_geometry_rev_weight_list[0]),
|
2016-10-19 20:11:36 -04:00
|
|
|
number_of_compressed_geometries * sizeof(EdgeWeight));
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-23 11:13:36 -04:00
|
|
|
void LoadDatasourceInfo(const boost::filesystem::path &datasource_names_file,
|
|
|
|
const boost::filesystem::path &datasource_indexes_file)
|
2016-03-15 02:03:19 -04:00
|
|
|
{
|
2016-03-22 14:30:18 -04:00
|
|
|
boost::filesystem::ifstream datasources_stream(datasource_indexes_file, std::ios::binary);
|
|
|
|
if (!datasources_stream)
|
2016-03-15 02:03:19 -04:00
|
|
|
{
|
2016-04-26 07:27:40 -04:00
|
|
|
throw util::exception("Could not open " + datasource_indexes_file.string() +
|
|
|
|
" for reading!");
|
2016-03-15 02:03:19 -04:00
|
|
|
}
|
2016-03-22 14:30:18 -04:00
|
|
|
BOOST_ASSERT(datasources_stream);
|
2016-03-15 02:03:19 -04:00
|
|
|
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto number_of_datasources = storage::io::readElementCount(datasources_stream);
|
2016-03-22 14:30:18 -04:00
|
|
|
if (number_of_datasources > 0)
|
2016-03-15 02:03:19 -04:00
|
|
|
{
|
2016-03-22 14:30:18 -04:00
|
|
|
m_datasource_list.resize(number_of_datasources);
|
2016-10-19 21:52:57 -04:00
|
|
|
storage::io::readDatasourceIndexes(
|
|
|
|
datasources_stream, &m_datasource_list.front(), number_of_datasources);
|
2016-03-22 14:30:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
boost::filesystem::ifstream datasourcenames_stream(datasource_names_file, std::ios::binary);
|
|
|
|
if (!datasourcenames_stream)
|
|
|
|
{
|
2016-04-26 07:27:40 -04:00
|
|
|
throw util::exception("Could not open " + datasource_names_file.string() +
|
|
|
|
" for reading!");
|
2016-03-22 14:30:18 -04:00
|
|
|
}
|
|
|
|
BOOST_ASSERT(datasourcenames_stream);
|
2016-10-19 21:52:57 -04:00
|
|
|
|
2016-10-21 18:24:55 -04:00
|
|
|
const auto datasource_names_data = storage::io::readDatasourceNames(datasourcenames_stream);
|
2016-10-19 21:52:57 -04:00
|
|
|
m_datasource_names.resize(datasource_names_data.lengths.size());
|
2016-10-21 18:24:55 -04:00
|
|
|
for (std::size_t i = 0; i < datasource_names_data.lengths.size(); ++i)
|
2016-03-22 14:30:18 -04:00
|
|
|
{
|
2016-10-19 21:52:57 -04:00
|
|
|
auto name_begin =
|
|
|
|
datasource_names_data.names.begin() + datasource_names_data.offsets[i];
|
|
|
|
auto name_end = datasource_names_data.names.begin() + datasource_names_data.offsets[i] +
|
|
|
|
datasource_names_data.lengths[i];
|
2016-10-21 18:24:55 -04:00
|
|
|
m_datasource_names[i] = std::string(name_begin, name_end);
|
2016-03-15 02:03:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
void LoadRTree()
|
|
|
|
{
|
2016-05-06 20:43:37 -04:00
|
|
|
BOOST_ASSERT_MSG(!m_coordinate_list.empty(), "coordinates must be loaded before r-tree");
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-12-03 14:04:23 -05:00
|
|
|
m_static_rtree.reset(new InternalRTree(ram_index_path, file_index_path, m_coordinate_list));
|
2016-03-03 08:26:13 -05:00
|
|
|
m_geospatial_query.reset(
|
|
|
|
new InternalGeospatialQuery(*m_static_rtree, m_coordinate_list, *this));
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:41:08 -04:00
|
|
|
void LoadLaneDescriptions(const boost::filesystem::path &lane_description_file)
|
2016-06-15 08:38:24 -04:00
|
|
|
{
|
2016-06-21 04:41:08 -04:00
|
|
|
if (!util::deserializeAdjacencyArray(lane_description_file.string(),
|
|
|
|
m_lane_description_offsets,
|
|
|
|
m_lane_description_masks))
|
|
|
|
util::SimpleLogger().Write(logWARNING) << "Failed to read turn lane descriptions from "
|
|
|
|
<< lane_description_file.string();
|
2016-06-15 08:38:24 -04:00
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
void LoadStreetNames(const boost::filesystem::path &names_file)
|
|
|
|
{
|
|
|
|
boost::filesystem::ifstream name_stream(names_file, std::ios::binary);
|
|
|
|
|
|
|
|
name_stream >> m_name_table;
|
|
|
|
|
|
|
|
unsigned number_of_chars = 0;
|
|
|
|
name_stream.read((char *)&number_of_chars, sizeof(unsigned));
|
|
|
|
BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken");
|
|
|
|
m_names_char_list.resize(number_of_chars + 1); //+1 gives sentinel element
|
|
|
|
name_stream.read((char *)&m_names_char_list[0], number_of_chars * sizeof(char));
|
|
|
|
if (0 == m_names_char_list.size())
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING) << "list of street names is empty";
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
void LoadIntersectionClasses(const boost::filesystem::path &intersection_class_file)
|
|
|
|
{
|
|
|
|
std::ifstream intersection_stream(intersection_class_file.string(), std::ios::binary);
|
|
|
|
if (!intersection_stream)
|
2016-05-10 02:37:45 -04:00
|
|
|
throw util::exception("Could not open " + intersection_class_file.string() +
|
|
|
|
" for reading.");
|
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
if (!util::readAndCheckFingerprint(intersection_stream))
|
2016-05-10 02:37:45 -04:00
|
|
|
throw util::exception("Fingeprint does not match in " +
|
|
|
|
intersection_class_file.string());
|
2016-04-26 07:27:40 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
util::SimpleLogger().Write(logINFO) << "Loading Bearing Class IDs";
|
|
|
|
std::vector<BearingClassID> bearing_class_id;
|
2016-05-10 02:37:45 -04:00
|
|
|
if (!util::deserializeVector(intersection_stream, bearing_class_id))
|
2016-05-27 15:05:04 -04:00
|
|
|
throw util::exception("Reading from " + intersection_class_file.string() +
|
|
|
|
" failed.");
|
2016-05-10 02:37:45 -04:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
m_bearing_class_id_table.resize(bearing_class_id.size());
|
2016-05-27 15:05:04 -04:00
|
|
|
std::copy(
|
|
|
|
bearing_class_id.begin(), bearing_class_id.end(), &m_bearing_class_id_table[0]);
|
2016-04-26 07:27:40 -04:00
|
|
|
}
|
|
|
|
{
|
|
|
|
util::SimpleLogger().Write(logINFO) << "Loading Bearing Classes";
|
2016-05-10 02:37:45 -04:00
|
|
|
// read the range table
|
|
|
|
intersection_stream >> m_bearing_ranges_table;
|
2016-04-26 07:27:40 -04:00
|
|
|
std::vector<util::guidance::BearingClass> bearing_classes;
|
2016-05-10 02:37:45 -04:00
|
|
|
// and the actual bearing values
|
|
|
|
std::uint64_t num_bearings;
|
2016-07-26 09:00:58 -04:00
|
|
|
intersection_stream.read(reinterpret_cast<char *>(&num_bearings), sizeof(num_bearings));
|
2016-05-10 02:37:45 -04:00
|
|
|
m_bearing_values_table.resize(num_bearings);
|
|
|
|
intersection_stream.read(reinterpret_cast<char *>(&m_bearing_values_table[0]),
|
|
|
|
sizeof(m_bearing_values_table[0]) * num_bearings);
|
|
|
|
if (!static_cast<bool>(intersection_stream))
|
2016-05-27 15:05:04 -04:00
|
|
|
throw util::exception("Reading from " + intersection_class_file.string() +
|
|
|
|
" failed.");
|
2016-04-26 07:27:40 -04:00
|
|
|
}
|
|
|
|
{
|
|
|
|
util::SimpleLogger().Write(logINFO) << "Loading Entry Classes";
|
|
|
|
std::vector<util::guidance::EntryClass> entry_classes;
|
2016-05-10 02:37:45 -04:00
|
|
|
if (!util::deserializeVector(intersection_stream, entry_classes))
|
2016-05-27 15:05:04 -04:00
|
|
|
throw util::exception("Reading from " + intersection_class_file.string() +
|
|
|
|
" failed.");
|
2016-05-10 02:37:45 -04:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
m_entry_class_table.resize(entry_classes.size());
|
|
|
|
std::copy(entry_classes.begin(), entry_classes.end(), &m_entry_class_table[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
public:
|
|
|
|
virtual ~InternalDataFacade()
|
|
|
|
{
|
|
|
|
m_static_rtree.reset();
|
2015-12-03 14:04:23 -05:00
|
|
|
m_geospatial_query.reset();
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
explicit InternalDataFacade(const storage::StorageConfig &config)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-03-22 14:30:18 -04:00
|
|
|
ram_index_path = config.ram_index_path;
|
|
|
|
file_index_path = config.file_index_path;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading graph data";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadGraph(config.hsgr_data_path);
|
2015-09-08 19:57:29 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading edge information";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadNodeAndEdgeInformation(config.nodes_data_path, config.edges_data_path);
|
2015-09-08 19:57:29 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading core information";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadCoreInformation(config.core_data_path);
|
2015-09-08 19:57:29 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading geometries";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadGeometries(config.geometries_path);
|
2015-09-08 19:57:29 -04:00
|
|
|
|
2016-03-15 02:03:19 -04:00
|
|
|
util::SimpleLogger().Write() << "loading datasource info";
|
2016-04-26 07:27:40 -04:00
|
|
|
LoadDatasourceInfo(config.datasource_names_path, config.datasource_indexes_path);
|
2016-03-15 02:03:19 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading timestamp";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadTimestamp(config.timestamp_path);
|
2015-09-08 19:57:29 -04:00
|
|
|
|
2016-03-21 18:34:59 -04:00
|
|
|
util::SimpleLogger().Write() << "loading profile properties";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadProfileProperties(config.properties_path);
|
2016-03-21 18:34:59 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading street names";
|
2016-03-22 14:30:18 -04:00
|
|
|
LoadStreetNames(config.names_data_path);
|
2016-05-06 19:53:11 -04:00
|
|
|
|
2016-06-15 08:38:24 -04:00
|
|
|
util::SimpleLogger().Write() << "loading lane tags";
|
2016-06-21 04:41:08 -04:00
|
|
|
LoadLaneDescriptions(config.turn_lane_description_path);
|
2016-06-15 08:38:24 -04:00
|
|
|
|
2016-05-06 19:53:11 -04:00
|
|
|
util::SimpleLogger().Write() << "loading rtree";
|
|
|
|
LoadRTree();
|
2016-04-26 07:27:40 -04:00
|
|
|
|
|
|
|
util::SimpleLogger().Write() << "loading intersection class data";
|
|
|
|
LoadIntersectionClasses(config.intersection_class_path);
|
2016-06-15 08:38:24 -04:00
|
|
|
|
|
|
|
util::SimpleLogger().Write() << "Loading Lane Data Pairs";
|
2016-10-04 15:28:13 -04:00
|
|
|
LoadLaneTupleIdPairs(config.turn_lane_data_path);
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// search graph access
|
2015-01-28 04:10:28 -05:00
|
|
|
unsigned GetNumberOfNodes() const override final { return m_query_graph->GetNumberOfNodes(); }
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
unsigned GetNumberOfEdges() const override final { return m_query_graph->GetNumberOfEdges(); }
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
unsigned GetOutDegree(const NodeID n) const override final
|
|
|
|
{
|
|
|
|
return m_query_graph->GetOutDegree(n);
|
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
NodeID GetTarget(const EdgeID e) const override final { return m_query_graph->GetTarget(e); }
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-01-28 10:28:44 -05:00
|
|
|
EdgeData &GetEdgeData(const EdgeID e) const override final
|
2015-01-28 04:10:28 -05:00
|
|
|
{
|
|
|
|
return m_query_graph->GetEdgeData(e);
|
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
EdgeID BeginEdges(const NodeID n) const override final { return m_query_graph->BeginEdges(n); }
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
EdgeID EndEdges(const NodeID n) const override final { return m_query_graph->EndEdges(n); }
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
EdgeRange GetAdjacentEdgeRange(const NodeID node) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_query_graph->GetAdjacentEdgeRange(node);
|
2016-03-14 11:25:39 -04:00
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
|
|
|
// searches for a specific edge
|
2015-01-28 04:10:28 -05:00
|
|
|
EdgeID FindEdge(const NodeID from, const NodeID to) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_query_graph->FindEdge(from, to);
|
|
|
|
}
|
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
EdgeID FindEdgeInEitherDirection(const NodeID from, const NodeID to) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_query_graph->FindEdgeInEitherDirection(from, to);
|
|
|
|
}
|
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
EdgeID
|
|
|
|
FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_query_graph->FindEdgeIndicateIfReverse(from, to, result);
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:26:48 -04:00
|
|
|
EdgeID FindSmallestEdge(const NodeID from,
|
|
|
|
const NodeID to,
|
|
|
|
std::function<bool(EdgeData)> filter) const override final
|
|
|
|
{
|
|
|
|
return m_query_graph->FindSmallestEdge(from, to, filter);
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
// node and edge information access
|
2016-02-23 15:23:13 -05:00
|
|
|
util::Coordinate GetCoordinateOfNode(const unsigned id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-05-06 20:43:37 -04:00
|
|
|
return m_coordinate_list[id];
|
2016-03-14 11:25:39 -04:00
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-05-18 16:09:14 -04:00
|
|
|
OSMNodeID GetOSMNodeIDOfNode(const unsigned id) const override final
|
|
|
|
{
|
2016-05-23 20:13:32 -04:00
|
|
|
return m_osmnodeid_list.at(id);
|
2016-05-18 16:09:14 -04:00
|
|
|
}
|
|
|
|
|
2016-03-03 09:36:03 -05:00
|
|
|
extractor::guidance::TurnInstruction
|
|
|
|
GetTurnInstructionForEdgeID(const unsigned id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_turn_instruction_list.at(id);
|
|
|
|
}
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const override final
|
2015-02-05 09:20:15 -05:00
|
|
|
{
|
|
|
|
return m_travel_mode_list.at(id);
|
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-02-23 15:23:13 -05:00
|
|
|
std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
|
2016-05-06 20:56:08 -04:00
|
|
|
const util::Coordinate north_east) const override final
|
2016-02-16 13:51:04 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-05-27 15:05:04 -04:00
|
|
|
const util::RectangleInt2D bbox{
|
|
|
|
south_west.lon, north_east.lon, south_west.lat, north_east.lat};
|
2016-02-16 13:51:04 -05:00
|
|
|
return m_geospatial_query->Search(bbox);
|
|
|
|
}
|
|
|
|
|
2016-02-20 22:27:26 -05:00
|
|
|
std::vector<PhantomNodeWithDistance>
|
2016-02-23 15:23:13 -05:00
|
|
|
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
2016-05-06 20:56:08 -04:00
|
|
|
const float max_distance) const override final
|
2016-02-20 22:27:26 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-02-20 22:27:26 -05:00
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance);
|
|
|
|
}
|
|
|
|
|
2015-12-09 16:34:22 -05:00
|
|
|
std::vector<PhantomNodeWithDistance>
|
2016-02-23 15:23:13 -05:00
|
|
|
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
2015-12-03 14:04:23 -05:00
|
|
|
const float max_distance,
|
2016-02-20 22:27:26 -05:00
|
|
|
const int bearing,
|
2016-05-06 20:56:08 -04:00
|
|
|
const int bearing_range) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
return m_geospatial_query->NearestPhantomNodesInRange(
|
|
|
|
input_coordinate, max_distance, bearing, bearing_range);
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-02-22 18:44:35 -05:00
|
|
|
std::vector<PhantomNodeWithDistance>
|
2016-02-23 15:23:13 -05:00
|
|
|
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
2016-05-06 20:56:08 -04:00
|
|
|
const unsigned max_results) const override final
|
2016-02-22 18:44:35 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-02-22 18:44:35 -05:00
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results);
|
|
|
|
}
|
|
|
|
|
2015-12-09 16:34:22 -05:00
|
|
|
std::vector<PhantomNodeWithDistance>
|
2016-02-23 15:23:13 -05:00
|
|
|
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
2015-12-03 14:04:23 -05:00
|
|
|
const unsigned max_results,
|
2016-05-06 20:56:08 -04:00
|
|
|
const double max_distance) const override final
|
2016-02-22 18:44:35 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-02-22 18:44:35 -05:00
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<PhantomNodeWithDistance>
|
2016-02-23 15:23:13 -05:00
|
|
|
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
2016-02-22 18:44:35 -05:00
|
|
|
const unsigned max_results,
|
|
|
|
const int bearing,
|
2016-05-06 20:56:08 -04:00
|
|
|
const int bearing_range) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
return m_geospatial_query->NearestPhantomNodes(
|
|
|
|
input_coordinate, max_results, bearing, bearing_range);
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-02-22 18:44:35 -05:00
|
|
|
std::vector<PhantomNodeWithDistance>
|
2016-02-23 15:23:13 -05:00
|
|
|
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
2016-02-22 18:44:35 -05:00
|
|
|
const unsigned max_results,
|
|
|
|
const double max_distance,
|
|
|
|
const int bearing,
|
2016-05-06 20:56:08 -04:00
|
|
|
const int bearing_range) const override final
|
2016-02-22 18:44:35 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-02-22 18:44:35 -05:00
|
|
|
|
2016-05-27 15:05:04 -04:00
|
|
|
return m_geospatial_query->NearestPhantomNodes(
|
|
|
|
input_coordinate, max_results, max_distance, bearing, bearing_range);
|
2016-02-22 18:44:35 -05:00
|
|
|
}
|
|
|
|
|
2016-05-10 02:37:45 -04:00
|
|
|
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
|
|
|
const util::Coordinate input_coordinate, const double max_distance) const override final
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-01-28 10:28:44 -05:00
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
|
|
|
input_coordinate, max_distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
2016-05-06 20:56:08 -04:00
|
|
|
const util::Coordinate input_coordinate) const override final
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-01-28 10:28:44 -05:00
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
|
|
|
input_coordinate);
|
|
|
|
}
|
|
|
|
|
2016-02-23 15:23:13 -05:00
|
|
|
std::pair<PhantomNode, PhantomNode>
|
|
|
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
|
|
|
const double max_distance,
|
|
|
|
const int bearing,
|
2016-05-06 20:56:08 -04:00
|
|
|
const int bearing_range) const override final
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2016-01-28 10:28:44 -05:00
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
|
|
|
input_coordinate, max_distance, bearing, bearing_range);
|
|
|
|
}
|
|
|
|
|
2016-02-23 15:23:13 -05:00
|
|
|
std::pair<PhantomNode, PhantomNode>
|
|
|
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
|
|
|
const int bearing,
|
2016-05-06 20:56:08 -04:00
|
|
|
const int bearing_range) const override final
|
2014-09-23 12:46:14 -04:00
|
|
|
{
|
2016-05-06 19:53:11 -04:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2014-09-23 12:46:14 -04:00
|
|
|
|
2016-01-05 06:04:04 -05:00
|
|
|
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
|
|
|
input_coordinate, bearing, bearing_range);
|
2014-09-23 12:46:14 -04:00
|
|
|
}
|
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
unsigned GetCheckSum() const override final { return m_check_sum; }
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
unsigned GetNameIndexFromEdgeID(const unsigned id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_name_ID_list.at(id);
|
2015-02-26 04:11:33 -05:00
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-03-18 14:21:13 -04:00
|
|
|
std::string GetNameForID(const unsigned name_id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2015-02-26 04:11:33 -05:00
|
|
|
if (std::numeric_limits<unsigned>::max() == name_id)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2015-02-26 04:11:33 -05:00
|
|
|
return "";
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
auto range = m_name_table.GetRange(name_id);
|
|
|
|
|
2015-02-26 04:11:33 -05:00
|
|
|
std::string result;
|
|
|
|
result.reserve(range.size());
|
2015-01-27 06:35:29 -05:00
|
|
|
if (range.begin() != range.end())
|
|
|
|
{
|
|
|
|
result.resize(range.back() - range.front() + 1);
|
|
|
|
std::copy(m_names_char_list.begin() + range.front(),
|
2016-05-27 15:05:04 -04:00
|
|
|
m_names_char_list.begin() + range.back() + 1,
|
|
|
|
result.begin());
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
2015-02-26 04:11:33 -05:00
|
|
|
return result;
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-09-05 09:01:51 -04:00
|
|
|
std::string GetRefForID(const unsigned name_id) const override final
|
|
|
|
{
|
|
|
|
// We store the ref after the name, destination and pronunciation of a street.
|
|
|
|
// We do this to get around the street length limit of 255 which would hit
|
|
|
|
// if we concatenate these. Order (see extractor_callbacks):
|
|
|
|
// name (0), destination (1), pronunciation (2), ref (3)
|
|
|
|
return GetNameForID(name_id + 3);
|
|
|
|
}
|
|
|
|
|
2016-05-25 21:35:38 -04:00
|
|
|
std::string GetPronunciationForID(const unsigned name_id) const override final
|
|
|
|
{
|
2016-06-02 10:35:21 -04:00
|
|
|
// We store the pronunciation after the name and destination of a street.
|
2016-05-25 21:35:38 -04:00
|
|
|
// We do this to get around the street length limit of 255 which would hit
|
2016-05-26 18:47:46 -04:00
|
|
|
// if we concatenate these. Order (see extractor_callbacks):
|
|
|
|
// name (0), destination (1), pronunciation (2)
|
|
|
|
return GetNameForID(name_id + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetDestinationsForID(const unsigned name_id) const override final
|
|
|
|
{
|
|
|
|
// We store the destination after the name of a street.
|
|
|
|
// We do this to get around the street length limit of 255 which would hit
|
|
|
|
// if we concatenate these. Order (see extractor_callbacks):
|
|
|
|
// name (0), destination (1), pronunciation (2)
|
2016-05-25 21:35:38 -04:00
|
|
|
return GetNameForID(name_id + 1);
|
|
|
|
}
|
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
virtual GeometryID GetGeometryIndexForEdgeID(const unsigned id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-07-22 12:23:54 -04:00
|
|
|
return m_via_geometry_list.at(id);
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:04:04 -05:00
|
|
|
virtual std::size_t GetCoreSize() const override final { return m_is_core_node.size(); }
|
2015-11-25 15:45:09 -05:00
|
|
|
|
2015-08-09 12:31:11 -04:00
|
|
|
virtual bool IsCoreNode(const NodeID id) const override final
|
|
|
|
{
|
2015-08-19 05:44:49 -04:00
|
|
|
if (m_is_core_node.size() > 0)
|
|
|
|
{
|
|
|
|
return m_is_core_node[id];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-08-09 12:31:11 -04:00
|
|
|
}
|
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
virtual std::vector<NodeID> GetUncompressedForwardGeometry(const EdgeID id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2016-07-22 12:23:54 -04:00
|
|
|
/*
|
|
|
|
* NodeID's for geometries are stored in one place for
|
|
|
|
* both forward and reverse segments along the same bi-
|
|
|
|
* directional edge. The m_geometry_indices stores
|
|
|
|
* refences to where to find the beginning of the bi-
|
2016-10-07 00:06:33 -04:00
|
|
|
* directional edge in the m_geometry_node_list vector. For
|
|
|
|
* forward geometries of bi-directional edges, edges 2 to
|
|
|
|
* n of that edge need to be read.
|
|
|
|
*/
|
2015-01-27 06:35:29 -05:00
|
|
|
const unsigned begin = m_geometry_indices.at(id);
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1);
|
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
std::vector<NodeID> result_nodes;
|
|
|
|
|
2016-10-19 16:58:20 -04:00
|
|
|
result_nodes.resize(end - begin);
|
2016-07-22 12:23:54 -04:00
|
|
|
|
2016-10-19 16:58:20 -04:00
|
|
|
std::copy(m_geometry_node_list.begin() + begin,
|
|
|
|
m_geometry_node_list.begin() + end,
|
|
|
|
result_nodes.begin());
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
return result_nodes;
|
2016-01-29 20:52:20 -05:00
|
|
|
}
|
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
virtual std::vector<NodeID> GetUncompressedReverseGeometry(const EdgeID id) const override final
|
2016-01-29 20:52:20 -05:00
|
|
|
{
|
2016-07-22 12:23:54 -04:00
|
|
|
/*
|
|
|
|
* NodeID's for geometries are stored in one place for
|
|
|
|
* both forward and reverse segments along the same bi-
|
|
|
|
* directional edge. The m_geometry_indices stores
|
|
|
|
* refences to where to find the beginning of the bi-
|
2016-10-07 00:06:33 -04:00
|
|
|
* directional edge in the m_geometry_node_list vector.
|
2016-07-22 12:23:54 -04:00
|
|
|
* */
|
2016-10-19 20:11:36 -04:00
|
|
|
const unsigned begin = m_geometry_indices.at(id);
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1);
|
2016-01-29 20:52:20 -05:00
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
std::vector<NodeID> result_nodes;
|
|
|
|
|
2016-10-19 16:58:20 -04:00
|
|
|
result_nodes.resize(end - begin);
|
2016-07-22 12:23:54 -04:00
|
|
|
|
2016-10-19 16:58:20 -04:00
|
|
|
std::copy(m_geometry_node_list.rbegin() + (m_geometry_node_list.size() - end),
|
|
|
|
m_geometry_node_list.rbegin() + (m_geometry_node_list.size() - begin),
|
|
|
|
result_nodes.begin());
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
return result_nodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::vector<EdgeWeight>
|
|
|
|
GetUncompressedForwardWeights(const EdgeID id) const override final
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* EdgeWeights's for geometries are stored in one place for
|
|
|
|
* both forward and reverse segments along the same bi-
|
|
|
|
* directional edge. The m_geometry_indices stores
|
|
|
|
* refences to where to find the beginning of the bi-
|
2016-10-07 00:06:33 -04:00
|
|
|
* directional edge in the m_geometry_fwd_weight_list vector.
|
|
|
|
* */
|
2016-07-22 12:23:54 -04:00
|
|
|
const unsigned begin = m_geometry_indices.at(id) + 1;
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1);
|
|
|
|
|
|
|
|
std::vector<EdgeWeight> result_weights;
|
2016-10-19 16:58:20 -04:00
|
|
|
result_weights.resize(end - begin);
|
2016-07-22 12:23:54 -04:00
|
|
|
|
2016-10-19 16:58:20 -04:00
|
|
|
std::copy(m_geometry_fwd_weight_list.begin() + begin,
|
|
|
|
m_geometry_fwd_weight_list.begin() + end,
|
|
|
|
result_weights.begin());
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
return result_weights;
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
virtual std::vector<EdgeWeight>
|
|
|
|
GetUncompressedReverseWeights(const EdgeID id) const override final
|
2016-03-15 02:03:19 -04:00
|
|
|
{
|
2016-07-22 12:23:54 -04:00
|
|
|
/*
|
|
|
|
* EdgeWeights for geometries are stored in one place for
|
|
|
|
* both forward and reverse segments along the same bi-
|
|
|
|
* directional edge. The m_geometry_indices stores
|
|
|
|
* refences to where to find the beginning of the bi-
|
2016-10-07 00:06:33 -04:00
|
|
|
* directional edge in the m_geometry_rev_weight_list vector. For
|
2016-07-22 12:23:54 -04:00
|
|
|
* reverse weights of bi-directional edges, edges 1 to
|
|
|
|
* n-1 of that edge need to be read in reverse.
|
|
|
|
*/
|
2016-10-19 20:11:36 -04:00
|
|
|
const unsigned begin = m_geometry_indices.at(id);
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1) - 1;
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
std::vector<EdgeWeight> result_weights;
|
2016-10-19 16:58:20 -04:00
|
|
|
result_weights.resize(end - begin);
|
2016-07-22 12:23:54 -04:00
|
|
|
|
2016-10-19 16:58:20 -04:00
|
|
|
std::copy(m_geometry_rev_weight_list.rbegin() + (m_geometry_rev_weight_list.size() - end),
|
|
|
|
m_geometry_rev_weight_list.rbegin() + (m_geometry_rev_weight_list.size() - begin),
|
|
|
|
result_weights.begin());
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
return result_weights;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the data source ids that were used to supply the edge
|
|
|
|
// weights.
|
|
|
|
virtual std::vector<uint8_t>
|
|
|
|
GetUncompressedForwardDatasources(const EdgeID id) const override final
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Data sources for geometries are stored in one place for
|
|
|
|
* both forward and reverse segments along the same bi-
|
|
|
|
* directional edge. The m_geometry_indices stores
|
|
|
|
* refences to where to find the beginning of the bi-
|
|
|
|
* directional edge in the m_geometry_list vector. For
|
|
|
|
* forward datasources of bi-directional edges, edges 2 to
|
|
|
|
* n of that edge need to be read.
|
|
|
|
*/
|
|
|
|
const unsigned begin = m_geometry_indices.at(id) + 1;
|
2016-03-15 02:03:19 -04:00
|
|
|
const unsigned end = m_geometry_indices.at(id + 1);
|
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
std::vector<uint8_t> result_datasources;
|
2016-10-19 16:58:20 -04:00
|
|
|
result_datasources.resize(end - begin);
|
2016-03-15 02:03:19 -04:00
|
|
|
|
|
|
|
// If there was no datasource info, return an array of 0's.
|
|
|
|
if (m_datasource_list.empty())
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < end - begin; ++i)
|
|
|
|
{
|
|
|
|
result_datasources.push_back(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-19 20:11:36 -04:00
|
|
|
std::copy(m_datasource_list.begin() + begin,
|
|
|
|
m_datasource_list.begin() + end,
|
|
|
|
result_datasources.begin());
|
2016-03-15 02:03:19 -04:00
|
|
|
}
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
return result_datasources;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the data source ids that were used to supply the edge
|
|
|
|
// weights.
|
|
|
|
virtual std::vector<uint8_t>
|
|
|
|
GetUncompressedReverseDatasources(const EdgeID id) const override final
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Datasources for geometries are stored in one place for
|
|
|
|
* both forward and reverse segments along the same bi-
|
|
|
|
* directional edge. The m_geometry_indices stores
|
|
|
|
* refences to where to find the beginning of the bi-
|
|
|
|
* directional edge in the m_geometry_list vector. For
|
|
|
|
* reverse datasources of bi-directional edges, edges 1 to
|
|
|
|
* n-1 of that edge need to be read in reverse.
|
|
|
|
*/
|
|
|
|
const unsigned begin = m_geometry_indices.at(id);
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1) - 1;
|
|
|
|
|
|
|
|
std::vector<uint8_t> result_datasources;
|
2016-10-19 16:58:20 -04:00
|
|
|
result_datasources.resize(end - begin);
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
// If there was no datasource info, return an array of 0's.
|
|
|
|
if (m_datasource_list.empty())
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < end - begin; ++i)
|
|
|
|
{
|
|
|
|
result_datasources.push_back(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-19 20:11:36 -04:00
|
|
|
std::copy(m_datasource_list.rbegin() + (m_datasource_list.size() - end),
|
|
|
|
m_datasource_list.rbegin() + (m_datasource_list.size() - begin),
|
|
|
|
result_datasources.begin());
|
2016-07-22 12:23:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result_datasources;
|
2016-03-15 02:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string GetDatasourceName(const uint8_t datasource_name_id) const override final
|
|
|
|
{
|
2016-03-22 14:30:18 -04:00
|
|
|
BOOST_ASSERT(m_datasource_names.size() >= 1);
|
|
|
|
BOOST_ASSERT(m_datasource_names.size() > datasource_name_id);
|
2016-03-15 02:03:19 -04:00
|
|
|
return m_datasource_names[datasource_name_id];
|
|
|
|
}
|
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
std::string GetTimestamp() const override final { return m_timestamp; }
|
2016-03-21 18:34:59 -04:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
bool GetContinueStraightDefault() const override final
|
|
|
|
{
|
|
|
|
return m_profile_properties.continue_straight_at_waypoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
BearingClassID GetBearingClassID(const NodeID nid) const override final
|
|
|
|
{
|
|
|
|
return m_bearing_class_id_table.at(nid);
|
|
|
|
}
|
|
|
|
|
|
|
|
util::guidance::BearingClass
|
|
|
|
GetBearingClass(const BearingClassID bearing_class_id) const override final
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(bearing_class_id != INVALID_BEARING_CLASSID);
|
2016-05-10 02:37:45 -04:00
|
|
|
auto range = m_bearing_ranges_table.GetRange(bearing_class_id);
|
|
|
|
|
|
|
|
util::guidance::BearingClass result;
|
|
|
|
|
|
|
|
for (auto itr = m_bearing_values_table.begin() + range.front();
|
2016-05-27 15:05:04 -04:00
|
|
|
itr != m_bearing_values_table.begin() + range.back() + 1;
|
|
|
|
++itr)
|
2016-05-10 02:37:45 -04:00
|
|
|
result.add(*itr);
|
|
|
|
|
|
|
|
return result;
|
2016-04-26 07:27:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
EntryClassID GetEntryClassID(const EdgeID eid) const override final
|
|
|
|
{
|
|
|
|
return m_entry_class_id_list.at(eid);
|
|
|
|
}
|
|
|
|
|
2016-08-17 03:49:19 -04:00
|
|
|
util::guidance::TurnBearing PreTurnBearing(const EdgeID eid) const override final
|
|
|
|
{
|
|
|
|
return m_pre_turn_bearing.at(eid);
|
|
|
|
}
|
|
|
|
util::guidance::TurnBearing PostTurnBearing(const EdgeID eid) const override final
|
|
|
|
{
|
|
|
|
return m_post_turn_bearing.at(eid);
|
|
|
|
}
|
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
util::guidance::EntryClass GetEntryClass(const EntryClassID entry_class_id) const override final
|
|
|
|
{
|
|
|
|
return m_entry_class_table.at(entry_class_id);
|
|
|
|
}
|
2016-06-15 08:38:24 -04:00
|
|
|
|
|
|
|
bool hasLaneData(const EdgeID id) const override final
|
|
|
|
{
|
|
|
|
return m_lane_data_id[id] != INVALID_LANE_DATAID;
|
|
|
|
}
|
|
|
|
|
2016-10-04 15:28:13 -04:00
|
|
|
util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const override final
|
2016-06-15 08:38:24 -04:00
|
|
|
{
|
|
|
|
BOOST_ASSERT(hasLaneData(id));
|
2016-10-04 15:28:13 -04:00
|
|
|
return m_lane_tuple_id_pairs[m_lane_data_id[id]];
|
2016-06-15 08:38:24 -04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:41:08 -04:00
|
|
|
extractor::guidance::TurnLaneDescription
|
|
|
|
GetTurnDescription(const LaneDescriptionID lane_description_id) const override final
|
2016-06-15 08:38:24 -04:00
|
|
|
{
|
2016-06-21 04:41:08 -04:00
|
|
|
if (lane_description_id == INVALID_LANE_DESCRIPTIONID)
|
|
|
|
return {};
|
|
|
|
else
|
|
|
|
return extractor::guidance::TurnLaneDescription(
|
|
|
|
m_lane_description_masks.begin() + m_lane_description_offsets[lane_description_id],
|
|
|
|
m_lane_description_masks.begin() +
|
|
|
|
m_lane_description_offsets[lane_description_id + 1]);
|
2016-06-15 08:38:24 -04:00
|
|
|
}
|
2015-01-27 06:35:29 -05:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
#endif // INTERNAL_DATAFACADE_HPP
|