reformat Server/DataStructure according to guideline
This commit is contained in:
parent
db67f2ddf1
commit
996dbdde00
@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef QUERY_DATA_FACADE_H
|
#ifndef BASE_DATA_FACADE_H
|
||||||
#define QUERY_DATA_FACADE_H
|
#define BASE_DATA_FACADE_H
|
||||||
|
|
||||||
// Exposes all data access interfaces to the algorithms via base class ptr
|
// Exposes all data access interfaces to the algorithms via base class ptr
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
template<class EdgeDataT>
|
template <class EdgeDataT> class BaseDataFacade
|
||||||
class BaseDataFacade {
|
{
|
||||||
public:
|
public:
|
||||||
typedef EdgeBasedNode RTreeLeaf;
|
typedef EdgeBasedNode RTreeLeaf;
|
||||||
typedef EdgeDataT EdgeData;
|
typedef EdgeDataT EdgeData;
|
||||||
@ -70,57 +70,39 @@ public:
|
|||||||
// searches for a specific edge
|
// searches for a specific edge
|
||||||
virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0;
|
virtual EdgeID FindEdge(const NodeID from, const NodeID to) const = 0;
|
||||||
|
|
||||||
virtual EdgeID FindEdgeInEitherDirection(
|
virtual EdgeID FindEdgeInEitherDirection(const NodeID from, const NodeID to) const = 0;
|
||||||
const NodeID from,
|
|
||||||
const NodeID to
|
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
virtual EdgeID FindEdgeIndicateIfReverse(
|
virtual EdgeID
|
||||||
const NodeID from,
|
FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const = 0;
|
||||||
const NodeID to,
|
|
||||||
bool & result
|
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
virtual FixedPointCoordinate GetCoordinateOfNode(
|
virtual FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
||||||
const unsigned id
|
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
virtual bool EdgeIsCompressed(const unsigned id) const = 0;
|
virtual bool EdgeIsCompressed(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const = 0;
|
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual void GetUncompressedGeometry(
|
virtual void GetUncompressedGeometry(const unsigned id,
|
||||||
const unsigned id,
|
std::vector<unsigned> &result_nodes) const = 0;
|
||||||
std::vector<unsigned> & result_nodes
|
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
virtual TurnInstruction GetTurnInstructionForEdgeID(
|
virtual TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
||||||
const unsigned id
|
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
virtual bool LocateClosestEndPointForCoordinate(
|
virtual bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
const FixedPointCoordinate& input_coordinate,
|
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
const unsigned zoom_level = 18
|
const unsigned zoom_level = 18) const = 0;
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
virtual bool FindPhantomNodeForCoordinate(
|
virtual bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
const FixedPointCoordinate & input_coordinate,
|
|
||||||
PhantomNode &resulting_phantom_node,
|
PhantomNode &resulting_phantom_node,
|
||||||
const unsigned zoom_level
|
const unsigned zoom_level) const = 0;
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
virtual unsigned GetCheckSum() const = 0;
|
virtual unsigned GetCheckSum() const = 0;
|
||||||
|
|
||||||
virtual unsigned GetNameIndexFromEdgeID(const unsigned id) const = 0;
|
virtual unsigned GetNameIndexFromEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual void GetName(
|
virtual void GetName(const unsigned name_id, std::string &result) const = 0;
|
||||||
const unsigned name_id,
|
|
||||||
std::string & result
|
|
||||||
) const = 0;
|
|
||||||
|
|
||||||
std::string GetEscapedNameForNameID(const unsigned name_id) const {
|
std::string GetEscapedNameForNameID(const unsigned name_id) const
|
||||||
|
{
|
||||||
std::string temporary_string;
|
std::string temporary_string;
|
||||||
GetName(name_id, temporary_string);
|
GetName(name_id, temporary_string);
|
||||||
return EscapeJSONString(temporary_string);
|
return EscapeJSONString(temporary_string);
|
||||||
@ -129,4 +111,4 @@ public:
|
|||||||
virtual std::string GetTimestamp() const = 0;
|
virtual std::string GetTimestamp() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUERY_DATA_FACADE_H
|
#endif // BASE_DATA_FACADE_H
|
||||||
|
@ -48,8 +48,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
template<class EdgeDataT>
|
template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<EdgeDataT>
|
||||||
class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BaseDataFacade<EdgeDataT> super;
|
typedef BaseDataFacade<EdgeDataT> super;
|
||||||
@ -74,49 +74,45 @@ private:
|
|||||||
ShM<unsigned, false>::vector m_geometry_indices;
|
ShM<unsigned, false>::vector m_geometry_indices;
|
||||||
ShM<unsigned, false>::vector m_geometry_list;
|
ShM<unsigned, false>::vector m_geometry_list;
|
||||||
|
|
||||||
boost::shared_ptr<
|
boost::shared_ptr<StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, false>::vector, false>>
|
||||||
StaticRTree<
|
m_static_rtree;
|
||||||
RTreeLeaf,
|
|
||||||
ShM<FixedPointCoordinate, false>::vector,
|
|
||||||
false
|
|
||||||
>
|
|
||||||
> m_static_rtree;
|
|
||||||
|
|
||||||
|
void LoadTimestamp(const boost::filesystem::path ×tamp_path)
|
||||||
void LoadTimestamp(const boost::filesystem::path & timestamp_path) {
|
{
|
||||||
if( boost::filesystem::exists(timestamp_path) ) {
|
if (boost::filesystem::exists(timestamp_path))
|
||||||
|
{
|
||||||
SimpleLogger().Write() << "Loading Timestamp";
|
SimpleLogger().Write() << "Loading Timestamp";
|
||||||
boost::filesystem::ifstream timestampInStream(timestamp_path);
|
boost::filesystem::ifstream timestampInStream(timestamp_path);
|
||||||
if(!timestampInStream) {
|
if (!timestampInStream)
|
||||||
|
{
|
||||||
SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
||||||
}
|
}
|
||||||
getline(timestampInStream, m_timestamp);
|
getline(timestampInStream, m_timestamp);
|
||||||
timestampInStream.close();
|
timestampInStream.close();
|
||||||
}
|
}
|
||||||
if(m_timestamp.empty()) {
|
if (m_timestamp.empty())
|
||||||
|
{
|
||||||
m_timestamp = "n/a";
|
m_timestamp = "n/a";
|
||||||
}
|
}
|
||||||
if(25 < m_timestamp.length()) {
|
if (25 < m_timestamp.length())
|
||||||
|
{
|
||||||
m_timestamp.resize(25);
|
m_timestamp.resize(25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGraph(const boost::filesystem::path & hsgr_path) {
|
void LoadGraph(const boost::filesystem::path &hsgr_path)
|
||||||
|
{
|
||||||
typename ShM<typename QueryGraph::NodeArrayEntry, false>::vector node_list;
|
typename ShM<typename QueryGraph::NodeArrayEntry, false>::vector node_list;
|
||||||
typename ShM<typename QueryGraph::EdgeArrayEntry, false>::vector edge_list;
|
typename ShM<typename QueryGraph::EdgeArrayEntry, false>::vector edge_list;
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
||||||
|
|
||||||
m_number_of_nodes = readHSGRFromStream(
|
m_number_of_nodes = readHSGRFromStream(hsgr_path, node_list, edge_list, &m_check_sum);
|
||||||
hsgr_path,
|
|
||||||
node_list,
|
|
||||||
edge_list,
|
|
||||||
&m_check_sum
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
||||||
// BOOST_ASSERT_MSG(0 != edge_list.size(), "edge list empty");
|
// BOOST_ASSERT_MSG(0 != edge_list.size(), "edge list empty");
|
||||||
SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and " << edge_list.size() << " edges";
|
SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and " << edge_list.size()
|
||||||
|
<< " edges";
|
||||||
m_query_graph = new QueryGraph(node_list, edge_list);
|
m_query_graph = new QueryGraph(node_list, edge_list);
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
||||||
@ -124,37 +120,26 @@ private:
|
|||||||
SimpleLogger().Write() << "Data checksum is " << m_check_sum;
|
SimpleLogger().Write() << "Data checksum is " << m_check_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadNodeAndEdgeInformation(
|
void LoadNodeAndEdgeInformation(const boost::filesystem::path &nodes_file,
|
||||||
const boost::filesystem::path & nodes_file,
|
const boost::filesystem::path &edges_file)
|
||||||
const boost::filesystem::path & edges_file
|
{
|
||||||
) {
|
boost::filesystem::ifstream nodes_input_stream(nodes_file, std::ios::binary);
|
||||||
boost::filesystem::ifstream nodes_input_stream(
|
|
||||||
nodes_file,
|
|
||||||
std::ios::binary
|
|
||||||
);
|
|
||||||
|
|
||||||
NodeInfo current_node;
|
NodeInfo current_node;
|
||||||
unsigned number_of_coordinates = 0;
|
unsigned number_of_coordinates = 0;
|
||||||
nodes_input_stream.read(
|
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
||||||
(char *)&number_of_coordinates,
|
m_coordinate_list =
|
||||||
sizeof(unsigned)
|
boost::make_shared<std::vector<FixedPointCoordinate>>(number_of_coordinates);
|
||||||
);
|
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
||||||
m_coordinate_list = boost::make_shared<std::vector<FixedPointCoordinate> >(number_of_coordinates);
|
{
|
||||||
for(unsigned i = 0; i < number_of_coordinates; ++i) {
|
|
||||||
nodes_input_stream.read((char *)¤t_node, sizeof(NodeInfo));
|
nodes_input_stream.read((char *)¤t_node, sizeof(NodeInfo));
|
||||||
m_coordinate_list->at(i) = FixedPointCoordinate(
|
m_coordinate_list->at(i) = FixedPointCoordinate(current_node.lat, current_node.lon);
|
||||||
current_node.lat,
|
|
||||||
current_node.lon
|
|
||||||
);
|
|
||||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lat) >> 30) == 0);
|
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lat) >> 30) == 0);
|
||||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lon) >> 30) == 0);
|
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lon) >> 30) == 0);
|
||||||
}
|
}
|
||||||
nodes_input_stream.close();
|
nodes_input_stream.close();
|
||||||
|
|
||||||
boost::filesystem::ifstream edges_input_stream(
|
boost::filesystem::ifstream edges_input_stream(edges_file, std::ios::binary);
|
||||||
edges_file,
|
|
||||||
std::ios::binary
|
|
||||||
);
|
|
||||||
unsigned number_of_edges = 0;
|
unsigned number_of_edges = 0;
|
||||||
edges_input_stream.read((char *)&number_of_edges, sizeof(unsigned));
|
edges_input_stream.read((char *)&number_of_edges, sizeof(unsigned));
|
||||||
m_via_node_list.resize(number_of_edges);
|
m_via_node_list.resize(number_of_edges);
|
||||||
@ -165,16 +150,15 @@ private:
|
|||||||
unsigned compressed = 0;
|
unsigned compressed = 0;
|
||||||
|
|
||||||
OriginalEdgeData current_edge_data;
|
OriginalEdgeData current_edge_data;
|
||||||
for(unsigned i = 0; i < number_of_edges; ++i) {
|
for (unsigned i = 0; i < number_of_edges; ++i)
|
||||||
edges_input_stream.read(
|
{
|
||||||
(char*)&(current_edge_data),
|
edges_input_stream.read((char *)&(current_edge_data), sizeof(OriginalEdgeData));
|
||||||
sizeof(OriginalEdgeData)
|
|
||||||
);
|
|
||||||
m_via_node_list[i] = current_edge_data.via_node;
|
m_via_node_list[i] = current_edge_data.via_node;
|
||||||
m_name_ID_list[i] = current_edge_data.name_id;
|
m_name_ID_list[i] = current_edge_data.name_id;
|
||||||
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
||||||
m_egde_is_compressed[i] = current_edge_data.compressed_geometry;
|
m_egde_is_compressed[i] = current_edge_data.compressed_geometry;
|
||||||
if(m_egde_is_compressed[i]) {
|
if (m_egde_is_compressed[i])
|
||||||
|
{
|
||||||
++compressed;
|
++compressed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,58 +168,37 @@ private:
|
|||||||
|
|
||||||
void LoadGeometries(const boost::filesystem::path &geometry_file)
|
void LoadGeometries(const boost::filesystem::path &geometry_file)
|
||||||
{
|
{
|
||||||
std::ifstream geometry_stream(
|
std::ifstream geometry_stream(geometry_file.c_str(), std::ios::binary);
|
||||||
geometry_file.c_str(),
|
|
||||||
std::ios::binary
|
|
||||||
);
|
|
||||||
unsigned number_of_indices = 0;
|
unsigned number_of_indices = 0;
|
||||||
unsigned number_of_compressed_geometries = 0;
|
unsigned number_of_compressed_geometries = 0;
|
||||||
|
|
||||||
geometry_stream.read(
|
geometry_stream.read((char *)&number_of_indices, sizeof(unsigned));
|
||||||
(char *)&number_of_indices,
|
|
||||||
sizeof(unsigned)
|
|
||||||
);
|
|
||||||
|
|
||||||
m_geometry_indices.resize(number_of_indices);
|
m_geometry_indices.resize(number_of_indices);
|
||||||
geometry_stream.read(
|
geometry_stream.read((char *)&(m_geometry_indices[0]),
|
||||||
(char *)&(m_geometry_indices[0]),
|
number_of_indices * sizeof(unsigned));
|
||||||
number_of_indices*sizeof(unsigned)
|
|
||||||
);
|
|
||||||
|
|
||||||
geometry_stream.read(
|
geometry_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned));
|
||||||
(char *)&number_of_compressed_geometries,
|
|
||||||
sizeof(unsigned)
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOST_ASSERT(m_geometry_indices.back() == number_of_compressed_geometries);
|
BOOST_ASSERT(m_geometry_indices.back() == number_of_compressed_geometries);
|
||||||
m_geometry_list.resize(number_of_compressed_geometries);
|
m_geometry_list.resize(number_of_compressed_geometries);
|
||||||
|
|
||||||
geometry_stream.read(
|
geometry_stream.read((char *)&(m_geometry_list[0]),
|
||||||
(char *)&(m_geometry_list[0]),
|
number_of_compressed_geometries * sizeof(unsigned));
|
||||||
number_of_compressed_geometries*sizeof(unsigned)
|
|
||||||
);
|
|
||||||
geometry_stream.close();
|
geometry_stream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadRTree(
|
void LoadRTree(const boost::filesystem::path &ram_index_path,
|
||||||
const boost::filesystem::path & ram_index_path,
|
const boost::filesystem::path &file_index_path)
|
||||||
const boost::filesystem::path & file_index_path
|
{
|
||||||
) {
|
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
|
||||||
BOOST_ASSERT_MSG(
|
|
||||||
!m_coordinate_list->empty(),
|
|
||||||
"coordinates must be loaded before r-tree"
|
|
||||||
);
|
|
||||||
|
|
||||||
m_static_rtree = boost::make_shared<StaticRTree<RTreeLeaf>>(
|
m_static_rtree = boost::make_shared<StaticRTree<RTreeLeaf>>(
|
||||||
ram_index_path,
|
ram_index_path, file_index_path, m_coordinate_list);
|
||||||
file_index_path,
|
|
||||||
m_coordinate_list
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadStreetNames(
|
void LoadStreetNames(const boost::filesystem::path &names_file)
|
||||||
const boost::filesystem::path & names_file
|
{
|
||||||
) {
|
|
||||||
boost::filesystem::ifstream name_stream(names_file, std::ios::binary);
|
boost::filesystem::ifstream name_stream(names_file, std::ios::binary);
|
||||||
unsigned number_of_names = 0;
|
unsigned number_of_names = 0;
|
||||||
unsigned number_of_chars = 0;
|
unsigned number_of_chars = 0;
|
||||||
@ -245,49 +208,50 @@ private:
|
|||||||
BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken");
|
BOOST_ASSERT_MSG(0 != number_of_chars, "name file broken");
|
||||||
|
|
||||||
m_name_begin_indices.resize(number_of_names);
|
m_name_begin_indices.resize(number_of_names);
|
||||||
name_stream.read(
|
name_stream.read((char *)&m_name_begin_indices[0], number_of_names * sizeof(unsigned));
|
||||||
(char*)&m_name_begin_indices[0],
|
|
||||||
number_of_names*sizeof(unsigned)
|
|
||||||
);
|
|
||||||
|
|
||||||
m_names_char_list.resize(number_of_chars + 1); //+1 gives sentinel element
|
m_names_char_list.resize(number_of_chars + 1); //+1 gives sentinel element
|
||||||
name_stream.read(
|
name_stream.read((char *)&m_names_char_list[0], number_of_chars * sizeof(char));
|
||||||
(char *)&m_names_char_list[0],
|
BOOST_ASSERT_MSG(0 != m_names_char_list.size(), "could not load any names");
|
||||||
number_of_chars*sizeof(char)
|
|
||||||
);
|
|
||||||
BOOST_ASSERT_MSG(
|
|
||||||
0 != m_names_char_list.size(),
|
|
||||||
"could not load any names"
|
|
||||||
);
|
|
||||||
name_stream.close();
|
name_stream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~InternalDataFacade() {
|
~InternalDataFacade()
|
||||||
|
{
|
||||||
delete m_query_graph;
|
delete m_query_graph;
|
||||||
m_static_rtree.reset();
|
m_static_rtree.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit InternalDataFacade( const ServerPaths & server_paths ) {
|
explicit InternalDataFacade(const ServerPaths &server_paths)
|
||||||
|
{
|
||||||
// generate paths of data files
|
// generate paths of data files
|
||||||
if( server_paths.find("hsgrdata") == server_paths.end() ) {
|
if (server_paths.find("hsgrdata") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no hsgr file given in ini file");
|
throw OSRMException("no hsgr file given in ini file");
|
||||||
}
|
}
|
||||||
if( server_paths.find("ramindex") == server_paths.end() ) {
|
if (server_paths.find("ramindex") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no ram index file given in ini file");
|
throw OSRMException("no ram index file given in ini file");
|
||||||
}
|
}
|
||||||
if( server_paths.find("fileindex") == server_paths.end() ) {
|
if (server_paths.find("fileindex") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no leaf index file given in ini file");
|
throw OSRMException("no leaf index file given in ini file");
|
||||||
}
|
}
|
||||||
if( server_paths.find("geometries") == server_paths.end() ) {
|
if (server_paths.find("geometries") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no geometries file given in ini file");
|
throw OSRMException("no geometries file given in ini file");
|
||||||
}
|
}
|
||||||
if( server_paths.find("nodesdata") == server_paths.end() ) {
|
if (server_paths.find("nodesdata") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no nodes file given in ini file");
|
throw OSRMException("no nodes file given in ini file");
|
||||||
}
|
}
|
||||||
if( server_paths.find("edgesdata") == server_paths.end() ) {
|
if (server_paths.find("edgesdata") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no edges file given in ini file");
|
throw OSRMException("no edges file given in ini file");
|
||||||
}
|
}
|
||||||
if( server_paths.find("namesdata") == server_paths.end() ) {
|
if (server_paths.find("namesdata") == server_paths.end())
|
||||||
|
{
|
||||||
throw OSRMException("no names file given in ini file");
|
throw OSRMException("no names file given in ini file");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,154 +296,113 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search graph access
|
// search graph access
|
||||||
unsigned GetNumberOfNodes() const {
|
unsigned GetNumberOfNodes() const { return m_query_graph->GetNumberOfNodes(); }
|
||||||
return m_query_graph->GetNumberOfNodes();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetNumberOfEdges() const {
|
unsigned GetNumberOfEdges() const { return m_query_graph->GetNumberOfEdges(); }
|
||||||
return m_query_graph->GetNumberOfEdges();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetOutDegree( const NodeID n ) const {
|
unsigned GetOutDegree(const NodeID n) const { return m_query_graph->GetOutDegree(n); }
|
||||||
return m_query_graph->GetOutDegree(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeID GetTarget( const EdgeID e ) const {
|
NodeID GetTarget(const EdgeID e) const { return m_query_graph->GetTarget(e); }
|
||||||
return m_query_graph->GetTarget(e); }
|
|
||||||
|
|
||||||
EdgeDataT &GetEdgeData( const EdgeID e ) {
|
EdgeDataT &GetEdgeData(const EdgeID e) { return m_query_graph->GetEdgeData(e); }
|
||||||
return m_query_graph->GetEdgeData(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
const EdgeDataT &GetEdgeData( const EdgeID e ) const {
|
const EdgeDataT &GetEdgeData(const EdgeID e) const { return m_query_graph->GetEdgeData(e); }
|
||||||
return m_query_graph->GetEdgeData(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeID BeginEdges( const NodeID n ) const {
|
EdgeID BeginEdges(const NodeID n) const { return m_query_graph->BeginEdges(n); }
|
||||||
return m_query_graph->BeginEdges(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeID EndEdges( const NodeID n ) const {
|
EdgeID EndEdges(const NodeID n) const { return m_query_graph->EndEdges(n); }
|
||||||
return m_query_graph->EndEdges(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// searches for a specific edge
|
// searches for a specific edge
|
||||||
EdgeID FindEdge( const NodeID from, const NodeID to ) const {
|
EdgeID FindEdge(const NodeID from, const NodeID to) const
|
||||||
|
{
|
||||||
return m_query_graph->FindEdge(from, to);
|
return m_query_graph->FindEdge(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeID FindEdgeInEitherDirection(
|
EdgeID FindEdgeInEitherDirection(const NodeID from, const NodeID to) const
|
||||||
const NodeID from,
|
{
|
||||||
const NodeID to
|
|
||||||
) const {
|
|
||||||
return m_query_graph->FindEdgeInEitherDirection(from, to);
|
return m_query_graph->FindEdgeInEitherDirection(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeID FindEdgeIndicateIfReverse(
|
EdgeID FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const
|
||||||
const NodeID from,
|
{
|
||||||
const NodeID to,
|
|
||||||
bool & result
|
|
||||||
) const {
|
|
||||||
return m_query_graph->FindEdgeIndicateIfReverse(from, to, result);
|
return m_query_graph->FindEdgeIndicateIfReverse(from, to, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
FixedPointCoordinate GetCoordinateOfNode(
|
FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const
|
||||||
const unsigned id
|
{
|
||||||
) const {
|
|
||||||
return m_coordinate_list->at(id);
|
return m_coordinate_list->at(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool EdgeIsCompressed( const unsigned id ) const {
|
bool EdgeIsCompressed(const unsigned id) const { return m_egde_is_compressed.at(id); }
|
||||||
return m_egde_is_compressed.at(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
TurnInstruction GetTurnInstructionForEdgeID(
|
TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const
|
||||||
const unsigned id
|
{
|
||||||
) const {
|
|
||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(
|
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
const FixedPointCoordinate& input_coordinate,
|
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
const unsigned zoom_level = 18
|
const unsigned zoom_level = 18) const
|
||||||
) const {
|
{
|
||||||
return m_static_rtree->LocateClosestEndPointForCoordinate(
|
return m_static_rtree->LocateClosestEndPointForCoordinate(
|
||||||
input_coordinate,
|
input_coordinate, result, zoom_level);
|
||||||
result,
|
|
||||||
zoom_level
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindPhantomNodeForCoordinate(
|
bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
const FixedPointCoordinate & input_coordinate,
|
|
||||||
PhantomNode &resulting_phantom_node,
|
PhantomNode &resulting_phantom_node,
|
||||||
const unsigned zoom_level
|
const unsigned zoom_level) const
|
||||||
) const {
|
{
|
||||||
const bool found = m_static_rtree->FindPhantomNodeForCoordinate(
|
const bool found = m_static_rtree->FindPhantomNodeForCoordinate(
|
||||||
input_coordinate,
|
input_coordinate, resulting_phantom_node, zoom_level);
|
||||||
resulting_phantom_node,
|
|
||||||
zoom_level
|
|
||||||
);
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetCheckSum() const { return m_check_sum; }
|
unsigned GetCheckSum() const { return m_check_sum; }
|
||||||
|
|
||||||
unsigned GetNameIndexFromEdgeID(const unsigned id) const {
|
unsigned GetNameIndexFromEdgeID(const unsigned id) const
|
||||||
|
{
|
||||||
return m_name_ID_list.at(id);
|
return m_name_ID_list.at(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
void GetName( const unsigned name_id, std::string & result ) const {
|
void GetName(const unsigned name_id, std::string &result) const
|
||||||
if(UINT_MAX == name_id) {
|
{
|
||||||
|
if (UINT_MAX == name_id)
|
||||||
|
{
|
||||||
result = "";
|
result = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BOOST_ASSERT_MSG(
|
BOOST_ASSERT_MSG(name_id < m_name_begin_indices.size(), "name id too high");
|
||||||
name_id < m_name_begin_indices.size(),
|
|
||||||
"name id too high"
|
|
||||||
);
|
|
||||||
const unsigned begin_index = m_name_begin_indices[name_id];
|
const unsigned begin_index = m_name_begin_indices[name_id];
|
||||||
const unsigned end_index = m_name_begin_indices[name_id + 1];
|
const unsigned end_index = m_name_begin_indices[name_id + 1];
|
||||||
BOOST_ASSERT_MSG(
|
BOOST_ASSERT_MSG(begin_index < m_names_char_list.size(), "begin index of name too high");
|
||||||
begin_index < m_names_char_list.size(),
|
BOOST_ASSERT_MSG(end_index < m_names_char_list.size(), "end index of name too high");
|
||||||
"begin index of name too high"
|
|
||||||
);
|
|
||||||
BOOST_ASSERT_MSG(
|
|
||||||
end_index < m_names_char_list.size(),
|
|
||||||
"end index of name too high"
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(begin_index <= end_index, "string ends before begin");
|
BOOST_ASSERT_MSG(begin_index <= end_index, "string ends before begin");
|
||||||
result.clear();
|
result.clear();
|
||||||
result.resize(end_index - begin_index);
|
result.resize(end_index - begin_index);
|
||||||
std::copy(
|
std::copy(m_names_char_list.begin() + begin_index,
|
||||||
m_names_char_list.begin() + begin_index,
|
|
||||||
m_names_char_list.begin() + end_index,
|
m_names_char_list.begin() + end_index,
|
||||||
result.begin()
|
result.begin());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const {
|
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const
|
||||||
|
{
|
||||||
return m_via_node_list.at(id);
|
return m_via_node_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void GetUncompressedGeometry(
|
virtual void GetUncompressedGeometry(const unsigned id, std::vector<unsigned> &result_nodes)
|
||||||
const unsigned id, std::vector<unsigned> & result_nodes
|
const
|
||||||
) const {
|
{
|
||||||
const unsigned begin = m_geometry_indices.at(id);
|
const unsigned begin = m_geometry_indices.at(id);
|
||||||
const unsigned end = m_geometry_indices.at(id + 1);
|
const unsigned end = m_geometry_indices.at(id + 1);
|
||||||
|
|
||||||
result_nodes.clear();
|
result_nodes.clear();
|
||||||
result_nodes.insert(result_nodes.begin(),
|
result_nodes.insert(
|
||||||
m_geometry_list.begin() + begin,
|
result_nodes.begin(), m_geometry_list.begin() + begin, m_geometry_list.begin() + end);
|
||||||
m_geometry_list.begin() + end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetTimestamp() const {
|
std::string GetTimestamp() const { return m_timestamp; }
|
||||||
return m_timestamp;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTERNAL_DATA_FACADE
|
#endif // INTERNAL_DATA_FACADE
|
||||||
|
@ -31,29 +31,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||||
#include <boost/interprocess/sync/named_condition.hpp>
|
#include <boost/interprocess/sync/named_condition.hpp>
|
||||||
|
|
||||||
struct SharedBarriers {
|
struct SharedBarriers
|
||||||
|
{
|
||||||
|
|
||||||
SharedBarriers()
|
SharedBarriers()
|
||||||
:
|
: pending_update_mutex(boost::interprocess::open_or_create, "pending_update"),
|
||||||
pending_update_mutex(
|
update_mutex(boost::interprocess::open_or_create, "update"),
|
||||||
boost::interprocess::open_or_create,
|
query_mutex(boost::interprocess::open_or_create, "query"),
|
||||||
"pending_update"
|
no_running_queries_condition(boost::interprocess::open_or_create, "no_running_queries"),
|
||||||
),
|
update_ongoing(false), number_of_queries(0)
|
||||||
update_mutex(
|
{
|
||||||
boost::interprocess::open_or_create,
|
}
|
||||||
"update"
|
|
||||||
),
|
|
||||||
query_mutex(
|
|
||||||
boost::interprocess::open_or_create,
|
|
||||||
"query"
|
|
||||||
),
|
|
||||||
no_running_queries_condition(
|
|
||||||
boost::interprocess::open_or_create,
|
|
||||||
"no_running_queries"
|
|
||||||
),
|
|
||||||
update_ongoing(false),
|
|
||||||
number_of_queries(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
// Mutex to protect access to the boolean variable
|
// Mutex to protect access to the boolean variable
|
||||||
boost::interprocess::named_mutex pending_update_mutex;
|
boost::interprocess::named_mutex pending_update_mutex;
|
||||||
|
@ -44,8 +44,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
template<class EdgeDataT>
|
template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDataT>
|
||||||
class SharedDataFacade : public BaseDataFacade<EdgeDataT> {
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef EdgeDataT EdgeData;
|
typedef EdgeDataT EdgeData;
|
||||||
@ -55,7 +55,8 @@ private:
|
|||||||
typedef typename StaticGraph<EdgeData, true>::EdgeArrayEntry GraphEdge;
|
typedef typename StaticGraph<EdgeData, true>::EdgeArrayEntry GraphEdge;
|
||||||
typedef typename QueryGraph::InputEdge InputEdge;
|
typedef typename QueryGraph::InputEdge InputEdge;
|
||||||
typedef typename super::RTreeLeaf RTreeLeaf;
|
typedef typename super::RTreeLeaf RTreeLeaf;
|
||||||
typedef typename StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>::TreeNode RTreeNode;
|
typedef typename StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>::TreeNode
|
||||||
|
RTreeNode;
|
||||||
|
|
||||||
SharedDataLayout *data_layout;
|
SharedDataLayout *data_layout;
|
||||||
char *shared_memory;
|
char *shared_memory;
|
||||||
@ -72,9 +73,7 @@ private:
|
|||||||
boost::shared_ptr<SharedMemory> m_large_memory;
|
boost::shared_ptr<SharedMemory> m_large_memory;
|
||||||
std::string m_timestamp;
|
std::string m_timestamp;
|
||||||
|
|
||||||
boost::shared_ptr<
|
boost::shared_ptr<ShM<FixedPointCoordinate, true>::vector> m_coordinate_list;
|
||||||
ShM<FixedPointCoordinate, true>::vector
|
|
||||||
> m_coordinate_list;
|
|
||||||
ShM<NodeID, true>::vector m_via_node_list;
|
ShM<NodeID, true>::vector m_via_node_list;
|
||||||
ShM<unsigned, true>::vector m_name_ID_list;
|
ShM<unsigned, true>::vector m_name_ID_list;
|
||||||
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
||||||
@ -84,164 +83,112 @@ private:
|
|||||||
ShM<unsigned, true>::vector m_geometry_indices;
|
ShM<unsigned, true>::vector m_geometry_indices;
|
||||||
ShM<unsigned, true>::vector m_geometry_list;
|
ShM<unsigned, true>::vector m_geometry_list;
|
||||||
|
|
||||||
boost::shared_ptr<
|
boost::shared_ptr<StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>>
|
||||||
StaticRTree<
|
m_static_rtree;
|
||||||
RTreeLeaf,
|
|
||||||
ShM<FixedPointCoordinate, true>::vector,
|
|
||||||
true
|
|
||||||
>
|
|
||||||
> m_static_rtree;
|
|
||||||
|
|
||||||
void LoadTimestamp() {
|
void LoadTimestamp()
|
||||||
|
{
|
||||||
char *timestamp_ptr = shared_memory + data_layout->GetTimeStampOffset();
|
char *timestamp_ptr = shared_memory + data_layout->GetTimeStampOffset();
|
||||||
m_timestamp.resize(data_layout->timestamp_length);
|
m_timestamp.resize(data_layout->timestamp_length);
|
||||||
std::copy(
|
std::copy(
|
||||||
timestamp_ptr,
|
timestamp_ptr, timestamp_ptr + data_layout->timestamp_length, m_timestamp.begin());
|
||||||
timestamp_ptr+data_layout->timestamp_length,
|
|
||||||
m_timestamp.begin()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadRTree(
|
void LoadRTree(const boost::filesystem::path &file_index_path)
|
||||||
const boost::filesystem::path & file_index_path
|
{
|
||||||
) {
|
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
|
||||||
BOOST_ASSERT_MSG(
|
|
||||||
!m_coordinate_list->empty(),
|
|
||||||
"coordinates must be loaded before r-tree"
|
|
||||||
);
|
|
||||||
|
|
||||||
RTreeNode * tree_ptr = (RTreeNode *)(
|
RTreeNode *tree_ptr = (RTreeNode *)(shared_memory + data_layout->GetRSearchTreeOffset());
|
||||||
shared_memory + data_layout->GetRSearchTreeOffset()
|
m_static_rtree = boost::make_shared<
|
||||||
);
|
StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>>(
|
||||||
m_static_rtree = boost::make_shared<StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true> >(
|
tree_ptr, data_layout->r_search_tree_size, file_index_path, m_coordinate_list);
|
||||||
tree_ptr,
|
|
||||||
data_layout->r_search_tree_size,
|
|
||||||
file_index_path,
|
|
||||||
m_coordinate_list
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGraph() {
|
void LoadGraph()
|
||||||
|
{
|
||||||
m_number_of_nodes = data_layout->graph_node_list_size;
|
m_number_of_nodes = data_layout->graph_node_list_size;
|
||||||
GraphNode * graph_nodes_ptr = (GraphNode *)(
|
GraphNode *graph_nodes_ptr =
|
||||||
shared_memory + data_layout->GetGraphNodeListOffset()
|
(GraphNode *)(shared_memory + data_layout->GetGraphNodeListOffset());
|
||||||
);
|
|
||||||
|
|
||||||
GraphEdge * graph_edges_ptr = (GraphEdge *)(
|
GraphEdge *graph_edges_ptr =
|
||||||
shared_memory + data_layout->GetGraphEdgeListOffset()
|
(GraphEdge *)(shared_memory + data_layout->GetGraphEdgeListOffset());
|
||||||
);
|
|
||||||
|
|
||||||
typename ShM<GraphNode, true>::vector node_list(
|
typename ShM<GraphNode, true>::vector node_list(graph_nodes_ptr,
|
||||||
graph_nodes_ptr,
|
data_layout->graph_node_list_size);
|
||||||
data_layout->graph_node_list_size
|
typename ShM<GraphEdge, true>::vector edge_list(graph_edges_ptr,
|
||||||
);
|
data_layout->graph_edge_list_size);
|
||||||
typename ShM<GraphEdge, true>::vector edge_list(
|
m_query_graph.reset(new QueryGraph(node_list, edge_list));
|
||||||
graph_edges_ptr,
|
|
||||||
data_layout->graph_edge_list_size
|
|
||||||
);
|
|
||||||
m_query_graph.reset(
|
|
||||||
new QueryGraph(node_list, edge_list)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadNodeAndEdgeInformation() {
|
void LoadNodeAndEdgeInformation()
|
||||||
|
{
|
||||||
|
|
||||||
FixedPointCoordinate * coordinate_list_ptr = (FixedPointCoordinate *)(
|
FixedPointCoordinate *coordinate_list_ptr =
|
||||||
shared_memory + data_layout->GetCoordinateListOffset()
|
(FixedPointCoordinate *)(shared_memory + data_layout->GetCoordinateListOffset());
|
||||||
);
|
|
||||||
m_coordinate_list = boost::make_shared<ShM<FixedPointCoordinate, true>::vector>(
|
m_coordinate_list = boost::make_shared<ShM<FixedPointCoordinate, true>::vector>(
|
||||||
coordinate_list_ptr,
|
coordinate_list_ptr, data_layout->coordinate_list_size);
|
||||||
data_layout->coordinate_list_size
|
|
||||||
);
|
|
||||||
|
|
||||||
TurnInstruction * turn_instruction_list_ptr = (TurnInstruction *)(
|
TurnInstruction *turn_instruction_list_ptr =
|
||||||
shared_memory + data_layout->GetTurnInstructionListOffset()
|
(TurnInstruction *)(shared_memory + data_layout->GetTurnInstructionListOffset());
|
||||||
);
|
|
||||||
typename ShM<TurnInstruction, true>::vector turn_instruction_list(
|
typename ShM<TurnInstruction, true>::vector turn_instruction_list(
|
||||||
turn_instruction_list_ptr,
|
turn_instruction_list_ptr, data_layout->turn_instruction_list_size);
|
||||||
data_layout->turn_instruction_list_size
|
|
||||||
);
|
|
||||||
m_turn_instruction_list.swap(turn_instruction_list);
|
m_turn_instruction_list.swap(turn_instruction_list);
|
||||||
|
|
||||||
unsigned * name_id_list_ptr = (unsigned *)(
|
unsigned *name_id_list_ptr =
|
||||||
shared_memory + data_layout->GetNameIDListOffset()
|
(unsigned *)(shared_memory + data_layout->GetNameIDListOffset());
|
||||||
);
|
typename ShM<unsigned, true>::vector name_id_list(name_id_list_ptr,
|
||||||
typename ShM<unsigned, true>::vector name_id_list(
|
data_layout->name_id_list_size);
|
||||||
name_id_list_ptr,
|
|
||||||
data_layout->name_id_list_size
|
|
||||||
);
|
|
||||||
m_name_ID_list.swap(name_id_list);
|
m_name_ID_list.swap(name_id_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadViaNodeList() {
|
void LoadViaNodeList()
|
||||||
NodeID * via_node_list_ptr = (NodeID *)(
|
{
|
||||||
shared_memory + data_layout->GetViaNodeListOffset()
|
NodeID *via_node_list_ptr = (NodeID *)(shared_memory + data_layout->GetViaNodeListOffset());
|
||||||
);
|
typename ShM<NodeID, true>::vector via_node_list(via_node_list_ptr,
|
||||||
typename ShM<NodeID, true>::vector via_node_list(
|
data_layout->via_node_list_size);
|
||||||
via_node_list_ptr,
|
|
||||||
data_layout->via_node_list_size
|
|
||||||
);
|
|
||||||
m_via_node_list.swap(via_node_list);
|
m_via_node_list.swap(via_node_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadNames() {
|
void LoadNames()
|
||||||
unsigned * street_names_index_ptr = (unsigned *)(
|
{
|
||||||
shared_memory + data_layout->GetNameIndexOffset()
|
unsigned *street_names_index_ptr =
|
||||||
);
|
(unsigned *)(shared_memory + data_layout->GetNameIndexOffset());
|
||||||
typename ShM<unsigned, true>::vector name_begin_indices(
|
typename ShM<unsigned, true>::vector name_begin_indices(street_names_index_ptr,
|
||||||
street_names_index_ptr,
|
data_layout->name_index_list_size);
|
||||||
data_layout->name_index_list_size
|
|
||||||
);
|
|
||||||
m_name_begin_indices.swap(name_begin_indices);
|
m_name_begin_indices.swap(name_begin_indices);
|
||||||
|
|
||||||
char * names_list_ptr = (char *)(
|
char *names_list_ptr = (char *)(shared_memory + data_layout->GetNameListOffset());
|
||||||
shared_memory + data_layout->GetNameListOffset()
|
typename ShM<char, true>::vector names_char_list(names_list_ptr,
|
||||||
);
|
data_layout->name_char_list_size);
|
||||||
typename ShM<char, true>::vector names_char_list(
|
|
||||||
names_list_ptr,
|
|
||||||
data_layout->name_char_list_size
|
|
||||||
);
|
|
||||||
m_names_char_list.swap(names_char_list);
|
m_names_char_list.swap(names_char_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGeometries()
|
void LoadGeometries()
|
||||||
{
|
{
|
||||||
unsigned * geometries_compressed_ptr = (unsigned *)(
|
unsigned *geometries_compressed_ptr =
|
||||||
shared_memory + data_layout->GetGeometriesIndicatorOffset()
|
(unsigned *)(shared_memory + data_layout->GetGeometriesIndicatorOffset());
|
||||||
);
|
typename ShM<bool, true>::vector egde_is_compressed(geometries_compressed_ptr,
|
||||||
typename ShM<bool, true>::vector egde_is_compressed(
|
data_layout->geometries_indicators);
|
||||||
geometries_compressed_ptr,
|
|
||||||
data_layout->geometries_indicators
|
|
||||||
);
|
|
||||||
m_egde_is_compressed.swap(egde_is_compressed);
|
m_egde_is_compressed.swap(egde_is_compressed);
|
||||||
|
|
||||||
unsigned * geometries_index_ptr = (unsigned *)(
|
unsigned *geometries_index_ptr =
|
||||||
shared_memory + data_layout->GetGeometriesIndexListOffset()
|
(unsigned *)(shared_memory + data_layout->GetGeometriesIndexListOffset());
|
||||||
);
|
|
||||||
typename ShM<unsigned, true>::vector geometry_begin_indices(
|
typename ShM<unsigned, true>::vector geometry_begin_indices(
|
||||||
geometries_index_ptr,
|
geometries_index_ptr, data_layout->geometries_index_list_size);
|
||||||
data_layout->geometries_index_list_size
|
|
||||||
);
|
|
||||||
m_geometry_indices.swap(geometry_begin_indices);
|
m_geometry_indices.swap(geometry_begin_indices);
|
||||||
|
|
||||||
unsigned * geometries_list_ptr = (unsigned *)(
|
unsigned *geometries_list_ptr =
|
||||||
shared_memory + data_layout->GetGeometryListOffset()
|
(unsigned *)(shared_memory + data_layout->GetGeometryListOffset());
|
||||||
);
|
typename ShM<unsigned, true>::vector geometry_list(geometries_list_ptr,
|
||||||
typename ShM<unsigned, true>::vector geometry_list(
|
data_layout->geometries_list_size);
|
||||||
geometries_list_ptr,
|
|
||||||
data_layout->geometries_list_size
|
|
||||||
);
|
|
||||||
m_geometry_list.swap(geometry_list);
|
m_geometry_list.swap(geometry_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SharedDataFacade( ) {
|
SharedDataFacade()
|
||||||
|
{
|
||||||
data_timestamp_ptr = (SharedDataTimestamp *)SharedMemoryFactory::Get(
|
data_timestamp_ptr = (SharedDataTimestamp *)SharedMemoryFactory::Get(
|
||||||
CURRENT_REGIONS,
|
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)->Ptr();
|
||||||
sizeof(SharedDataTimestamp),
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
)->Ptr();
|
|
||||||
|
|
||||||
CURRENT_LAYOUT = LAYOUT_NONE;
|
CURRENT_LAYOUT = LAYOUT_NONE;
|
||||||
CURRENT_DATA = DATA_NONE;
|
CURRENT_DATA = DATA_NONE;
|
||||||
@ -251,12 +198,12 @@ public:
|
|||||||
CheckAndReloadFacade();
|
CheckAndReloadFacade();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckAndReloadFacade() {
|
void CheckAndReloadFacade()
|
||||||
if(
|
{
|
||||||
CURRENT_LAYOUT != data_timestamp_ptr->layout ||
|
if (CURRENT_LAYOUT != data_timestamp_ptr->layout ||
|
||||||
CURRENT_DATA != data_timestamp_ptr->data ||
|
CURRENT_DATA != data_timestamp_ptr->data ||
|
||||||
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp
|
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
|
||||||
) {
|
{
|
||||||
// release the previous shared memory segments
|
// release the previous shared memory segments
|
||||||
SharedMemory::Remove(CURRENT_LAYOUT);
|
SharedMemory::Remove(CURRENT_LAYOUT);
|
||||||
SharedMemory::Remove(CURRENT_DATA);
|
SharedMemory::Remove(CURRENT_DATA);
|
||||||
@ -267,21 +214,16 @@ public:
|
|||||||
|
|
||||||
m_layout_memory.reset(SharedMemoryFactory::Get(CURRENT_LAYOUT));
|
m_layout_memory.reset(SharedMemoryFactory::Get(CURRENT_LAYOUT));
|
||||||
|
|
||||||
data_layout = (SharedDataLayout *)(
|
data_layout = (SharedDataLayout *)(m_layout_memory->Ptr());
|
||||||
m_layout_memory->Ptr()
|
|
||||||
);
|
|
||||||
boost::filesystem::path ram_index_path(data_layout->ram_index_file_name);
|
boost::filesystem::path ram_index_path(data_layout->ram_index_file_name);
|
||||||
if( !boost::filesystem::exists(ram_index_path) ) {
|
if (!boost::filesystem::exists(ram_index_path))
|
||||||
throw OSRMException(
|
{
|
||||||
"no leaf index file given. "
|
throw OSRMException("no leaf index file given. "
|
||||||
"Is any data loaded into shared memory?"
|
"Is any data loaded into shared memory?");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_large_memory.reset(SharedMemoryFactory::Get(CURRENT_DATA));
|
m_large_memory.reset(SharedMemoryFactory::Get(CURRENT_DATA));
|
||||||
shared_memory = (char *)(
|
shared_memory = (char *)(m_large_memory->Ptr());
|
||||||
m_large_memory->Ptr()
|
|
||||||
);
|
|
||||||
|
|
||||||
LoadGraph();
|
LoadGraph();
|
||||||
LoadNodeAndEdgeInformation();
|
LoadNodeAndEdgeInformation();
|
||||||
@ -296,154 +238,115 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search graph access
|
// search graph access
|
||||||
unsigned GetNumberOfNodes() const {
|
unsigned GetNumberOfNodes() const { return m_query_graph->GetNumberOfNodes(); }
|
||||||
return m_query_graph->GetNumberOfNodes();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetNumberOfEdges() const {
|
unsigned GetNumberOfEdges() const { return m_query_graph->GetNumberOfEdges(); }
|
||||||
return m_query_graph->GetNumberOfEdges();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetOutDegree( const NodeID n ) const {
|
unsigned GetOutDegree(const NodeID n) const { return m_query_graph->GetOutDegree(n); }
|
||||||
return m_query_graph->GetOutDegree(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeID GetTarget( const EdgeID e ) const {
|
NodeID GetTarget(const EdgeID e) const { return m_query_graph->GetTarget(e); }
|
||||||
return m_query_graph->GetTarget(e); }
|
|
||||||
|
|
||||||
EdgeDataT &GetEdgeData( const EdgeID e ) {
|
EdgeDataT &GetEdgeData(const EdgeID e) { return m_query_graph->GetEdgeData(e); }
|
||||||
return m_query_graph->GetEdgeData(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// const EdgeDataT &GetEdgeData( const EdgeID e ) const {
|
// const EdgeDataT &GetEdgeData( const EdgeID e ) const {
|
||||||
// return m_query_graph->GetEdgeData(e);
|
// return m_query_graph->GetEdgeData(e);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
EdgeID BeginEdges( const NodeID n ) const {
|
EdgeID BeginEdges(const NodeID n) const { return m_query_graph->BeginEdges(n); }
|
||||||
return m_query_graph->BeginEdges(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeID EndEdges( const NodeID n ) const {
|
EdgeID EndEdges(const NodeID n) const { return m_query_graph->EndEdges(n); }
|
||||||
return m_query_graph->EndEdges(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// searches for a specific edge
|
// searches for a specific edge
|
||||||
EdgeID FindEdge( const NodeID from, const NodeID to ) const {
|
EdgeID FindEdge(const NodeID from, const NodeID to) const
|
||||||
|
{
|
||||||
return m_query_graph->FindEdge(from, to);
|
return m_query_graph->FindEdge(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeID FindEdgeInEitherDirection(
|
EdgeID FindEdgeInEitherDirection(const NodeID from, const NodeID to) const
|
||||||
const NodeID from,
|
{
|
||||||
const NodeID to
|
|
||||||
) const {
|
|
||||||
return m_query_graph->FindEdgeInEitherDirection(from, to);
|
return m_query_graph->FindEdgeInEitherDirection(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeID FindEdgeIndicateIfReverse(
|
EdgeID FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const
|
||||||
const NodeID from,
|
{
|
||||||
const NodeID to,
|
|
||||||
bool & result
|
|
||||||
) const {
|
|
||||||
return m_query_graph->FindEdgeIndicateIfReverse(from, to, result);
|
return m_query_graph->FindEdgeIndicateIfReverse(from, to, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
FixedPointCoordinate GetCoordinateOfNode(
|
FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const
|
||||||
const unsigned id
|
{
|
||||||
) const {
|
|
||||||
return m_coordinate_list->at(id);
|
return m_coordinate_list->at(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool EdgeIsCompressed( const unsigned id ) const {
|
virtual bool EdgeIsCompressed(const unsigned id) const { return m_egde_is_compressed.at(id); }
|
||||||
return m_egde_is_compressed.at(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void GetUncompressedGeometry(
|
virtual void GetUncompressedGeometry(const unsigned id, std::vector<unsigned> &result_nodes)
|
||||||
const unsigned id, std::vector<unsigned> & result_nodes
|
const
|
||||||
) const {
|
{
|
||||||
const unsigned begin = m_geometry_indices.at(id);
|
const unsigned begin = m_geometry_indices.at(id);
|
||||||
const unsigned end = m_geometry_indices.at(id + 1);
|
const unsigned end = m_geometry_indices.at(id + 1);
|
||||||
|
|
||||||
result_nodes.clear();
|
result_nodes.clear();
|
||||||
result_nodes.insert(result_nodes.begin(),
|
result_nodes.insert(
|
||||||
m_geometry_list.begin() + begin,
|
result_nodes.begin(), m_geometry_list.begin() + begin, m_geometry_list.begin() + end);
|
||||||
m_geometry_list.begin() + end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const {
|
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const
|
||||||
|
{
|
||||||
return m_via_node_list.at(id);
|
return m_via_node_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TurnInstruction GetTurnInstructionForEdgeID(
|
TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const
|
||||||
const unsigned id
|
{
|
||||||
) const {
|
|
||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(
|
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
const FixedPointCoordinate& input_coordinate,
|
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
const unsigned zoom_level = 18
|
const unsigned zoom_level = 18) const
|
||||||
) const {
|
{
|
||||||
return m_static_rtree->LocateClosestEndPointForCoordinate(
|
return m_static_rtree->LocateClosestEndPointForCoordinate(
|
||||||
input_coordinate,
|
input_coordinate, result, zoom_level);
|
||||||
result,
|
|
||||||
zoom_level
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindPhantomNodeForCoordinate(
|
bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
const FixedPointCoordinate & input_coordinate,
|
|
||||||
PhantomNode &resulting_phantom_node,
|
PhantomNode &resulting_phantom_node,
|
||||||
const unsigned zoom_level
|
const unsigned zoom_level) const
|
||||||
) const {
|
{
|
||||||
const bool found = m_static_rtree->FindPhantomNodeForCoordinate(
|
const bool found = m_static_rtree->FindPhantomNodeForCoordinate(
|
||||||
input_coordinate,
|
input_coordinate, resulting_phantom_node, zoom_level);
|
||||||
resulting_phantom_node,
|
|
||||||
zoom_level
|
|
||||||
);
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetCheckSum() const { return m_check_sum; }
|
unsigned GetCheckSum() const { return m_check_sum; }
|
||||||
|
|
||||||
unsigned GetNameIndexFromEdgeID(const unsigned id) const {
|
unsigned GetNameIndexFromEdgeID(const unsigned id) const
|
||||||
|
{
|
||||||
return m_name_ID_list.at(id);
|
return m_name_ID_list.at(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
void GetName( const unsigned name_id, std::string & result ) const {
|
void GetName(const unsigned name_id, std::string &result) const
|
||||||
if(UINT_MAX == name_id) {
|
{
|
||||||
|
if (UINT_MAX == name_id)
|
||||||
|
{
|
||||||
result = "";
|
result = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BOOST_ASSERT_MSG(
|
BOOST_ASSERT_MSG(name_id < m_name_begin_indices.size(), "name id too high");
|
||||||
name_id < m_name_begin_indices.size(),
|
|
||||||
"name id too high"
|
|
||||||
);
|
|
||||||
const unsigned begin_index = m_name_begin_indices[name_id];
|
const unsigned begin_index = m_name_begin_indices[name_id];
|
||||||
const unsigned end_index = m_name_begin_indices[name_id + 1];
|
const unsigned end_index = m_name_begin_indices[name_id + 1];
|
||||||
BOOST_ASSERT_MSG(
|
BOOST_ASSERT_MSG(begin_index <= m_names_char_list.size(), "begin index of name too high");
|
||||||
begin_index <= m_names_char_list.size(),
|
BOOST_ASSERT_MSG(end_index <= m_names_char_list.size(), "end index of name too high");
|
||||||
"begin index of name too high"
|
|
||||||
);
|
|
||||||
BOOST_ASSERT_MSG(
|
|
||||||
end_index <= m_names_char_list.size(),
|
|
||||||
"end index of name too high"
|
|
||||||
);
|
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(begin_index <= end_index, "string ends before begin");
|
BOOST_ASSERT_MSG(begin_index <= end_index, "string ends before begin");
|
||||||
result.clear();
|
result.clear();
|
||||||
result.resize(end_index - begin_index);
|
result.resize(end_index - begin_index);
|
||||||
std::copy(
|
std::copy(m_names_char_list.begin() + begin_index,
|
||||||
m_names_char_list.begin() + begin_index,
|
|
||||||
m_names_char_list.begin() + end_index,
|
m_names_char_list.begin() + end_index,
|
||||||
result.begin()
|
result.begin());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetTimestamp() const {
|
std::string GetTimestamp() const { return m_timestamp; }
|
||||||
return m_timestamp;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARED_DATA_FACADE_H
|
#endif // SHARED_DATA_FACADE_H
|
||||||
|
@ -25,7 +25,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef SHARED_DATA_TYPE_H_
|
#ifndef SHARED_DATA_TYPE_H_
|
||||||
#define SHARED_DATA_TYPE_H_
|
#define SHARED_DATA_TYPE_H_
|
||||||
|
|
||||||
@ -46,7 +45,8 @@ typedef BaseDataFacade<QueryEdge::EdgeData>::RTreeLeaf RTreeLeaf;
|
|||||||
typedef StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>::TreeNode RTreeNode;
|
typedef StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>::TreeNode RTreeNode;
|
||||||
typedef StaticGraph<QueryEdge::EdgeData> QueryGraph;
|
typedef StaticGraph<QueryEdge::EdgeData> QueryGraph;
|
||||||
|
|
||||||
struct SharedDataLayout {
|
struct SharedDataLayout
|
||||||
|
{
|
||||||
uint64_t name_index_list_size;
|
uint64_t name_index_list_size;
|
||||||
uint64_t name_char_list_size;
|
uint64_t name_char_list_size;
|
||||||
uint64_t name_id_list_size;
|
uint64_t name_id_list_size;
|
||||||
@ -65,27 +65,19 @@ struct SharedDataLayout {
|
|||||||
|
|
||||||
char ram_index_file_name[1024];
|
char ram_index_file_name[1024];
|
||||||
|
|
||||||
SharedDataLayout() :
|
SharedDataLayout()
|
||||||
name_index_list_size(0),
|
: name_index_list_size(0), name_char_list_size(0), name_id_list_size(0),
|
||||||
name_char_list_size(0),
|
via_node_list_size(0), graph_node_list_size(0), graph_edge_list_size(0),
|
||||||
name_id_list_size(0),
|
coordinate_list_size(0), turn_instruction_list_size(0), r_search_tree_size(0),
|
||||||
via_node_list_size(0),
|
geometries_index_list_size(0), geometries_list_size(0), geometries_indicators(0),
|
||||||
graph_node_list_size(0),
|
checksum(0), timestamp_length(0)
|
||||||
graph_edge_list_size(0),
|
|
||||||
coordinate_list_size(0),
|
|
||||||
turn_instruction_list_size(0),
|
|
||||||
r_search_tree_size(0),
|
|
||||||
geometries_index_list_size(0),
|
|
||||||
geometries_list_size(0),
|
|
||||||
geometries_indicators(0),
|
|
||||||
checksum(0),
|
|
||||||
timestamp_length(0)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
ram_index_file_name[0] = '\0';
|
ram_index_file_name[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintInformation() const {
|
void PrintInformation() const
|
||||||
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "-";
|
SimpleLogger().Write(logDEBUG) << "-";
|
||||||
SimpleLogger().Write(logDEBUG) << "name_index_list_size: " << name_index_list_size;
|
SimpleLogger().Write(logDEBUG) << "name_index_list_size: " << name_index_list_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "name_char_list_size: " << name_char_list_size;
|
SimpleLogger().Write(logDEBUG) << "name_char_list_size: " << name_char_list_size;
|
||||||
@ -95,21 +87,23 @@ struct SharedDataLayout {
|
|||||||
SimpleLogger().Write(logDEBUG) << "graph_edge_list_size: " << graph_edge_list_size;
|
SimpleLogger().Write(logDEBUG) << "graph_edge_list_size: " << graph_edge_list_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "timestamp_length: " << timestamp_length;
|
SimpleLogger().Write(logDEBUG) << "timestamp_length: " << timestamp_length;
|
||||||
SimpleLogger().Write(logDEBUG) << "coordinate_list_size: " << coordinate_list_size;
|
SimpleLogger().Write(logDEBUG) << "coordinate_list_size: " << coordinate_list_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "turn_instruction_list_size: " << turn_instruction_list_size;
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "turn_instruction_list_size: " << turn_instruction_list_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "r_search_tree_size: " << r_search_tree_size;
|
SimpleLogger().Write(logDEBUG) << "r_search_tree_size: " << r_search_tree_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "geometries_indicators: " << geometries_indicators << "/" << ((geometries_indicators/8) + 1);
|
SimpleLogger().Write(logDEBUG) << "geometries_indicators: " << geometries_indicators
|
||||||
SimpleLogger().Write(logDEBUG) << "geometries_index_list_size: " << geometries_index_list_size;
|
<< "/" << ((geometries_indicators / 8) + 1);
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "geometries_index_list_size: " << geometries_index_list_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "geometries_list_size: " << geometries_list_size;
|
SimpleLogger().Write(logDEBUG) << "geometries_list_size: " << geometries_list_size;
|
||||||
SimpleLogger().Write(logDEBUG) << "sizeof(checksum): " << sizeof(checksum);
|
SimpleLogger().Write(logDEBUG) << "sizeof(checksum): " << sizeof(checksum);
|
||||||
SimpleLogger().Write(logDEBUG) << "ram index file name: " << ram_index_file_name;
|
SimpleLogger().Write(logDEBUG) << "ram index file name: " << ram_index_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSizeOfLayout() const {
|
uint64_t GetSizeOfLayout() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
@ -118,89 +112,79 @@ struct SharedDataLayout {
|
|||||||
(r_search_tree_size * sizeof(RTreeNode)) +
|
(r_search_tree_size * sizeof(RTreeNode)) +
|
||||||
(geometries_indicators / 32 + 1) * sizeof(unsigned) +
|
(geometries_indicators / 32 + 1) * sizeof(unsigned) +
|
||||||
(geometries_index_list_size * sizeof(unsigned)) +
|
(geometries_index_list_size * sizeof(unsigned)) +
|
||||||
(geometries_list_size * sizeof(unsigned) ) +
|
(geometries_list_size * sizeof(unsigned)) + sizeof(checksum) + 1024 * sizeof(char);
|
||||||
sizeof(checksum) +
|
|
||||||
1024*sizeof(char);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetNameIndexOffset() const {
|
uint64_t GetNameIndexOffset() const { return 0; }
|
||||||
return 0;
|
uint64_t GetNameListOffset() const
|
||||||
}
|
{
|
||||||
uint64_t GetNameListOffset() const {
|
uint64_t result = (name_index_list_size * sizeof(unsigned));
|
||||||
uint64_t result =
|
|
||||||
(name_index_list_size * sizeof(unsigned) );
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetNameIDListOffset() const {
|
uint64_t GetNameIDListOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char));
|
||||||
(name_char_list_size * sizeof(char) );
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetViaNodeListOffset() const {
|
uint64_t GetViaNodeListOffset() const
|
||||||
uint64_t result =
|
{
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
uint64_t result = (name_index_list_size * sizeof(unsigned)) +
|
||||||
(name_char_list_size * sizeof(char)) +
|
(name_char_list_size * sizeof(char)) +
|
||||||
(name_id_list_size * sizeof(unsigned));
|
(name_id_list_size * sizeof(unsigned));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetGraphNodeListOffset() const {
|
uint64_t GetGraphNodeListOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID));
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) );
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetGraphEdgeListOffset() const {
|
uint64_t GetGraphEdgeListOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry));
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetTimeStampOffset() const {
|
uint64_t GetTimeStampOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry));
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetCoordinateListOffset() const {
|
uint64_t GetCoordinateListOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char));
|
(timestamp_length * sizeof(char));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetTurnInstructionListOffset() const {
|
uint64_t GetTurnInstructionListOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
(coordinate_list_size * sizeof(FixedPointCoordinate));
|
(coordinate_list_size * sizeof(FixedPointCoordinate));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetRSearchTreeOffset() const {
|
uint64_t GetRSearchTreeOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
@ -208,12 +192,11 @@ struct SharedDataLayout {
|
|||||||
(turn_instruction_list_size * sizeof(TurnInstructionsClass));
|
(turn_instruction_list_size * sizeof(TurnInstructionsClass));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetGeometriesIndicatorOffset() const {
|
uint64_t GetGeometriesIndicatorOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
@ -224,11 +207,10 @@ struct SharedDataLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetGeometriesIndexListOffset() const
|
uint64_t GetGeometriesIndexListOffset() const
|
||||||
{ uint64_t result =
|
{
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
uint64_t result =
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
@ -239,12 +221,11 @@ struct SharedDataLayout {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetGeometryListOffset() const {
|
uint64_t GetGeometryListOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
@ -255,12 +236,11 @@ struct SharedDataLayout {
|
|||||||
(geometries_index_list_size * sizeof(unsigned));
|
(geometries_index_list_size * sizeof(unsigned));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint64_t GetChecksumOffset() const {
|
uint64_t GetChecksumOffset() const
|
||||||
|
{
|
||||||
uint64_t result =
|
uint64_t result =
|
||||||
(name_index_list_size * sizeof(unsigned) ) +
|
(name_index_list_size * sizeof(unsigned)) + (name_char_list_size * sizeof(char)) +
|
||||||
(name_char_list_size * sizeof(char) ) +
|
(name_id_list_size * sizeof(unsigned)) + (via_node_list_size * sizeof(NodeID)) +
|
||||||
(name_id_list_size * sizeof(unsigned) ) +
|
|
||||||
(via_node_list_size * sizeof(NodeID) ) +
|
|
||||||
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
(graph_node_list_size * sizeof(QueryGraph::NodeArrayEntry)) +
|
||||||
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
(graph_edge_list_size * sizeof(QueryGraph::EdgeArrayEntry)) +
|
||||||
(timestamp_length * sizeof(char)) +
|
(timestamp_length * sizeof(char)) +
|
||||||
@ -274,17 +254,17 @@ struct SharedDataLayout {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SharedDataType {
|
enum SharedDataType
|
||||||
CURRENT_REGIONS,
|
{ CURRENT_REGIONS,
|
||||||
LAYOUT_1,
|
LAYOUT_1,
|
||||||
DATA_1,
|
DATA_1,
|
||||||
LAYOUT_2,
|
LAYOUT_2,
|
||||||
DATA_2,
|
DATA_2,
|
||||||
LAYOUT_NONE,
|
LAYOUT_NONE,
|
||||||
DATA_NONE
|
DATA_NONE };
|
||||||
};
|
|
||||||
|
|
||||||
struct SharedDataTimestamp {
|
struct SharedDataTimestamp
|
||||||
|
{
|
||||||
SharedDataType layout;
|
SharedDataType layout;
|
||||||
SharedDataType data;
|
SharedDataType data;
|
||||||
unsigned timestamp;
|
unsigned timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user