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-01-02 11:13:44 -05:00
|
|
|
#include "engine/geospatial_query.hpp"
|
|
|
|
#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"
|
|
|
|
#include "contractor/query_edge.hpp"
|
|
|
|
#include "util/shared_memory_vector_wrapper.hpp"
|
|
|
|
#include "util/static_graph.hpp"
|
|
|
|
#include "util/static_rtree.hpp"
|
|
|
|
#include "util/range_table.hpp"
|
|
|
|
#include "util/graph_loader.hpp"
|
|
|
|
#include "util/simple_logger.hpp"
|
2016-02-16 13:51:04 -05:00
|
|
|
#include "util/rectangle.hpp"
|
2016-01-29 20:52:20 -05:00
|
|
|
#include "extractor/compressed_edge_container.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>;
|
2015-03-23 12:06:10 -04:00
|
|
|
using InputEdge = typename QueryGraph::InputEdge;
|
|
|
|
using RTreeLeaf = typename 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;
|
|
|
|
unsigned m_number_of_nodes;
|
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-02-23 15:23:13 -05:00
|
|
|
std::shared_ptr<util::ShM<util::Coordinate, false>::vector> m_coordinate_list;
|
2016-01-05 10:51:13 -05:00
|
|
|
util::ShM<NodeID, false>::vector m_via_node_list;
|
|
|
|
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-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-01-29 20:52:20 -05:00
|
|
|
util::ShM<extractor::CompressedEdgeContainer::CompressedEdge, false>::vector m_geometry_list;
|
2016-01-05 10:51:13 -05:00
|
|
|
util::ShM<bool, false>::vector m_is_core_node;
|
2016-01-29 20:52:20 -05:00
|
|
|
util::ShM<unsigned, false>::vector m_segment_weights;
|
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-03-21 18:34:59 -04:00
|
|
|
extractor::ProfileProperties m_profile_properties;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2015-12-03 14:04:23 -05:00
|
|
|
boost::thread_specific_ptr<InternalRTree> m_static_rtree;
|
|
|
|
boost::thread_specific_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-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.");
|
|
|
|
}
|
|
|
|
|
|
|
|
in_stream.read(reinterpret_cast<char*>(&m_profile_properties), sizeof(m_profile_properties));
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
void LoadTimestamp(const boost::filesystem::path ×tamp_path)
|
|
|
|
{
|
|
|
|
if (boost::filesystem::exists(timestamp_path))
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "Loading Timestamp";
|
2015-01-27 06:35:29 -05:00
|
|
|
boost::filesystem::ifstream timestamp_stream(timestamp_path);
|
|
|
|
if (!timestamp_stream)
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
getline(timestamp_stream, m_timestamp);
|
|
|
|
}
|
|
|
|
if (m_timestamp.empty())
|
|
|
|
{
|
|
|
|
m_timestamp = "n/a";
|
|
|
|
}
|
|
|
|
if (25 < m_timestamp.length())
|
|
|
|
{
|
|
|
|
m_timestamp.resize(25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoadGraph(const boost::filesystem::path &hsgr_path)
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
typename util::ShM<typename QueryGraph::NodeArrayEntry, false>::vector node_list;
|
|
|
|
typename util::ShM<typename QueryGraph::EdgeArrayEntry, false>::vector edge_list;
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
2015-01-27 06:35:29 -05:00
|
|
|
|
|
|
|
m_number_of_nodes = readHSGRFromStream(hsgr_path, node_list, edge_list, &m_check_sum);
|
|
|
|
|
|
|
|
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
|
|
|
// BOOST_ASSERT_MSG(0 != edge_list.size(), "edge list empty");
|
2016-01-07 19:31:57 -05:00
|
|
|
util::SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and "
|
|
|
|
<< edge_list.size() << " edges";
|
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
|
|
|
|
|
|
|
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
|
|
|
BOOST_ASSERT_MSG(0 == edge_list.size(), "edge list not flushed");
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void LoadNodeAndEdgeInformation(const boost::filesystem::path &nodes_file,
|
|
|
|
const boost::filesystem::path &edges_file)
|
|
|
|
{
|
|
|
|
boost::filesystem::ifstream nodes_input_stream(nodes_file, std::ios::binary);
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
extractor::QueryNode current_node;
|
2015-01-27 06:35:29 -05:00
|
|
|
unsigned number_of_coordinates = 0;
|
|
|
|
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
2016-02-23 15:23:13 -05:00
|
|
|
m_coordinate_list = std::make_shared<std::vector<util::Coordinate>>(number_of_coordinates);
|
2015-01-27 06:35:29 -05:00
|
|
|
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
2016-02-23 15:23:13 -05:00
|
|
|
m_coordinate_list->at(i) = util::Coordinate(current_node.lon, current_node.lat);
|
|
|
|
BOOST_ASSERT(m_coordinate_list->at(i).IsValid());
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
boost::filesystem::ifstream edges_input_stream(edges_file, std::ios::binary);
|
|
|
|
unsigned number_of_edges = 0;
|
|
|
|
edges_input_stream.read((char *)&number_of_edges, sizeof(unsigned));
|
|
|
|
m_via_node_list.resize(number_of_edges);
|
|
|
|
m_name_ID_list.resize(number_of_edges);
|
|
|
|
m_turn_instruction_list.resize(number_of_edges);
|
|
|
|
m_travel_mode_list.resize(number_of_edges);
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
extractor::OriginalEdgeData current_edge_data;
|
2015-01-27 06:35:29 -05:00
|
|
|
for (unsigned i = 0; i < number_of_edges; ++i)
|
|
|
|
{
|
2016-01-07 19:31:57 -05:00
|
|
|
edges_input_stream.read((char *)&(current_edge_data),
|
|
|
|
sizeof(extractor::OriginalEdgeData));
|
2015-01-27 06:35:29 -05:00
|
|
|
m_via_node_list[i] = current_edge_data.via_node;
|
|
|
|
m_name_ID_list[i] = current_edge_data.name_id;
|
|
|
|
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
|
|
|
m_travel_mode_list[i] = current_edge_data.travel_mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
m_geometry_list.resize(number_of_compressed_geometries);
|
|
|
|
|
|
|
|
if (number_of_compressed_geometries > 0)
|
|
|
|
{
|
|
|
|
geometry_stream.read((char *)&(m_geometry_list[0]),
|
2016-03-03 08:26:13 -05:00
|
|
|
number_of_compressed_geometries *
|
|
|
|
sizeof(extractor::CompressedEdgeContainer::CompressedEdge));
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-15 02:03:19 -04:00
|
|
|
void LoadDatasourceInfo(const boost::filesystem::path &datasource_names_file,
|
|
|
|
const boost::filesystem::path &datasource_indexes_file)
|
|
|
|
{
|
|
|
|
std::ifstream datasources_stream(datasource_indexes_file.c_str(), std::ios::binary);
|
|
|
|
if (datasources_stream)
|
|
|
|
{
|
|
|
|
std::size_t number_of_datasources = 0;
|
|
|
|
datasources_stream.read(reinterpret_cast<char *>(&number_of_datasources),
|
|
|
|
sizeof(std::size_t));
|
|
|
|
if (number_of_datasources > 0)
|
|
|
|
{
|
|
|
|
m_datasource_list.resize(number_of_datasources);
|
|
|
|
datasources_stream.read(reinterpret_cast<char *>(&(m_datasource_list[0])),
|
|
|
|
number_of_datasources * sizeof(uint8_t));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ifstream datasourcenames_stream(datasource_names_file.c_str(), std::ios::binary);
|
|
|
|
if (datasourcenames_stream)
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
while (std::getline(datasourcenames_stream, name))
|
|
|
|
{
|
|
|
|
m_datasource_names.push_back(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 06:35:29 -05:00
|
|
|
void LoadRTree()
|
|
|
|
{
|
|
|
|
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01-05 06:04:04 -05:00
|
|
|
explicit InternalDataFacade(
|
|
|
|
const std::unordered_map<std::string, boost::filesystem::path> &server_paths)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2015-09-08 19:57:29 -04:00
|
|
|
// cache end iterator to quickly check .find against
|
|
|
|
const auto end_it = end(server_paths);
|
|
|
|
|
|
|
|
const auto file_for = [&server_paths, &end_it](const std::string &path)
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
2015-09-08 19:57:29 -04:00
|
|
|
const auto it = server_paths.find(path);
|
|
|
|
if (it == end_it || !boost::filesystem::is_regular_file(it->second))
|
2016-01-05 10:51:13 -05:00
|
|
|
throw util::exception("no valid " + path + " file given in ini file");
|
2015-09-08 19:57:29 -04:00
|
|
|
return it->second;
|
|
|
|
};
|
|
|
|
|
2016-03-15 02:03:19 -04:00
|
|
|
const auto optional_file_for = [&server_paths, &end_it](const std::string &path)
|
|
|
|
{
|
|
|
|
const auto it = server_paths.find(path);
|
|
|
|
if (it == end_it)
|
|
|
|
throw util::exception("no valid " + path + " file given in ini file");
|
|
|
|
return it->second;
|
|
|
|
};
|
|
|
|
|
2015-09-08 19:57:29 -04:00
|
|
|
ram_index_path = file_for("ramindex");
|
|
|
|
file_index_path = file_for("fileindex");
|
2015-01-27 06:35:29 -05:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading graph data";
|
2015-09-08 19:57:29 -04:00
|
|
|
LoadGraph(file_for("hsgrdata"));
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading edge information";
|
2015-09-08 19:57:29 -04:00
|
|
|
LoadNodeAndEdgeInformation(file_for("nodesdata"), file_for("edgesdata"));
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading core information";
|
2015-09-08 19:57:29 -04:00
|
|
|
LoadCoreInformation(file_for("coredata"));
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading geometries";
|
2015-09-08 19:57:29 -04:00
|
|
|
LoadGeometries(file_for("geometries"));
|
|
|
|
|
2016-03-15 02:03:19 -04:00
|
|
|
util::SimpleLogger().Write() << "loading datasource info";
|
|
|
|
LoadDatasourceInfo(optional_file_for("datasource_names"),
|
|
|
|
optional_file_for("datasource_indexes"));
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading timestamp";
|
2015-09-08 19:57:29 -04:00
|
|
|
LoadTimestamp(file_for("timestamp"));
|
|
|
|
|
2016-03-21 18:34:59 -04:00
|
|
|
util::SimpleLogger().Write() << "loading profile properties";
|
|
|
|
LoadProfileProperties(file_for("properties"));
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "loading street names";
|
2015-09-08 19:57:29 -04:00
|
|
|
LoadStreetNames(file_for("namesdata"));
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
|
|
|
return m_coordinate_list->at(id);
|
2016-03-14 11:25:39 -04:00
|
|
|
}
|
2015-01-27 06:35:29 -05: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,
|
|
|
|
const util::Coordinate north_east) override final
|
2016-02-16 13:51:04 -05:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
2016-02-23 15:23:13 -05: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-02-20 22:27:26 -05:00
|
|
|
const float max_distance) override final
|
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
const int bearing_range) override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
2015-12-03 14:04:23 -05:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:04:04 -05: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-02-22 18:44:35 -05:00
|
|
|
const unsigned max_results) override final
|
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-22 18:44:35 -05:00
|
|
|
const double max_distance) override final
|
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
const int bearing_range) override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
2015-12-03 14:04:23 -05:00
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-01-05 06:04:04 -05: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,
|
|
|
|
const int bearing_range) override final
|
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance,
|
|
|
|
bearing, bearing_range);
|
|
|
|
}
|
|
|
|
|
2016-02-23 15:23:13 -05:00
|
|
|
std::pair<PhantomNode, PhantomNode>
|
|
|
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
|
|
|
const double max_distance) override final
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent(
|
|
|
|
input_coordinate, max_distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
2016-02-23 15:23:13 -05:00
|
|
|
const util::Coordinate input_coordinate) override final
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
const int bearing_range) override final
|
2016-01-28 10:28:44 -05:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
|
|
|
BOOST_ASSERT(m_geospatial_query.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
const int bearing_range) override final
|
2014-09-23 12:46:14 -04:00
|
|
|
{
|
|
|
|
if (!m_static_rtree.get())
|
|
|
|
{
|
|
|
|
LoadRTree();
|
2015-12-03 14:04:23 -05: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(),
|
|
|
|
m_names_char_list.begin() + range.back() + 1, result.begin());
|
|
|
|
}
|
2015-02-26 04:11:33 -05:00
|
|
|
return result;
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2015-01-28 04:10:28 -05:00
|
|
|
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const override final
|
2015-01-27 06:35:29 -05:00
|
|
|
{
|
|
|
|
return m_via_node_list.at(id);
|
|
|
|
}
|
|
|
|
|
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-01-29 20:52:20 -05:00
|
|
|
virtual void GetUncompressedGeometry(const EdgeID id,
|
|
|
|
std::vector<NodeID> &result_nodes) const override final
|
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);
|
|
|
|
|
|
|
|
result_nodes.clear();
|
2016-01-29 20:52:20 -05:00
|
|
|
result_nodes.reserve(end - begin);
|
2016-03-03 08:26:13 -05:00
|
|
|
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
|
|
|
|
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
|
|
|
|
{
|
|
|
|
result_nodes.emplace_back(edge.node_id);
|
|
|
|
});
|
2016-01-29 20:52:20 -05:00
|
|
|
}
|
|
|
|
|
2016-03-03 08:26:13 -05:00
|
|
|
virtual void
|
|
|
|
GetUncompressedWeights(const EdgeID id,
|
|
|
|
std::vector<EdgeWeight> &result_weights) const override final
|
2016-01-29 20:52:20 -05:00
|
|
|
{
|
|
|
|
const unsigned begin = m_geometry_indices.at(id);
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1);
|
|
|
|
|
|
|
|
result_weights.clear();
|
|
|
|
result_weights.reserve(end - begin);
|
2016-03-03 08:26:13 -05:00
|
|
|
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
|
|
|
|
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
|
|
|
|
{
|
|
|
|
result_weights.emplace_back(edge.weight);
|
|
|
|
});
|
2015-01-27 06:35:29 -05:00
|
|
|
}
|
|
|
|
|
2016-03-15 02:03:19 -04:00
|
|
|
// Returns the data source ids that were used to supply the edge
|
|
|
|
// weights.
|
|
|
|
virtual void
|
|
|
|
GetUncompressedDatasources(const EdgeID id,
|
|
|
|
std::vector<uint8_t> &result_datasources) const override final
|
|
|
|
{
|
|
|
|
const unsigned begin = m_geometry_indices.at(id);
|
|
|
|
const unsigned end = m_geometry_indices.at(id + 1);
|
|
|
|
|
|
|
|
result_datasources.clear();
|
|
|
|
result_datasources.reserve(end - begin);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
|
|
|
std::for_each(m_datasource_list.begin() + begin, m_datasource_list.begin() + end,
|
|
|
|
[&](const uint8_t &datasource_id)
|
|
|
|
{
|
|
|
|
result_datasources.push_back(datasource_id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string GetDatasourceName(const uint8_t datasource_name_id) const override final
|
|
|
|
{
|
|
|
|
if (m_datasource_names.empty() || datasource_name_id > m_datasource_names.size())
|
|
|
|
{
|
|
|
|
if (datasource_name_id == 0)
|
|
|
|
return "lua profile";
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
bool GetUTurnsDefault() const override final { return m_profile_properties.allow_u_turn_at_via; }
|
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
|