Split QueryNode into coordinates and osm id
This commit is contained in:
committed by
Patrick Niklaus
parent
786a3d8919
commit
7f6e0c478b
@@ -204,8 +204,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
using super = BaseDataFacade;
|
||||
using IndexBlock = util::RangeTable<16, storage::Ownership::View>::BlockT;
|
||||
using RTreeLeaf = super::RTreeLeaf;
|
||||
using SharedRTree =
|
||||
util::StaticRTree<RTreeLeaf, util::vector_view<util::Coordinate>, storage::Ownership::View>;
|
||||
using SharedRTree = util::StaticRTree<RTreeLeaf, storage::Ownership::View>;
|
||||
using SharedGeospatialQuery = GeospatialQuery<SharedRTree, BaseDataFacade>;
|
||||
using RTreeNode = SharedRTree::TreeNode;
|
||||
|
||||
@@ -215,7 +214,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
|
||||
unsigned m_check_sum;
|
||||
util::vector_view<util::Coordinate> m_coordinate_list;
|
||||
util::PackedVector<OSMNodeID, storage::Ownership::View> m_osmnodeid_list;
|
||||
util::PackedVectorView<OSMNodeID> m_osmnodeid_list;
|
||||
util::NameTable m_names_table;
|
||||
util::vector_view<std::uint32_t> m_lane_description_offsets;
|
||||
util::vector_view<extractor::guidance::TurnLaneType::Mask> m_lane_description_masks;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "extractor/restriction_map.hpp"
|
||||
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/packed_vector.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
@@ -72,7 +73,8 @@ class EdgeBasedGraphFactory
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const std::unordered_set<NodeID> &traffic_lights,
|
||||
std::shared_ptr<const RestrictionMap> restriction_map,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::PackedVector<OSMNodeID> &osm_node_ids,
|
||||
ProfileProperties profile_properties,
|
||||
const util::NameTable &name_table,
|
||||
std::vector<std::uint32_t> &turn_lane_offsets,
|
||||
@@ -128,7 +130,8 @@ class EdgeBasedGraphFactory
|
||||
util::DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
|
||||
EdgeID m_max_edge_id;
|
||||
|
||||
const std::vector<QueryNode> &m_node_info_list;
|
||||
const std::vector<util::Coordinate> &m_coordinates;
|
||||
const util::PackedVector<OSMNodeID> &m_osm_node_ids;
|
||||
std::shared_ptr<util::NodeBasedDynamicGraph> m_node_based_graph;
|
||||
std::shared_ptr<RestrictionMap const> m_restriction_map;
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ class Extractor
|
||||
|
||||
std::pair<std::size_t, EdgeID>
|
||||
BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
||||
std::vector<QueryNode> &internal_to_external_node_map,
|
||||
std::vector<util::Coordinate> &coordinates,
|
||||
util::PackedVector<OSMNodeID> &osm_node_ids,
|
||||
std::vector<EdgeBasedNode> &node_based_edge_list,
|
||||
std::vector<bool> &node_is_startpoint,
|
||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||
@@ -66,18 +67,18 @@ class Extractor
|
||||
const std::string &intersection_class_output_file);
|
||||
void WriteProfileProperties(const std::string &output_path,
|
||||
const ProfileProperties &properties) const;
|
||||
void WriteNodeMapping(const std::vector<QueryNode> &internal_to_external_node_map);
|
||||
void FindComponents(unsigned max_edge_id,
|
||||
const util::DeallocatingVector<EdgeBasedEdge> &edges,
|
||||
std::vector<EdgeBasedNode> &nodes) const;
|
||||
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||
std::vector<bool> node_is_startpoint,
|
||||
const std::vector<QueryNode> &internal_to_external_node_map);
|
||||
const std::vector<util::Coordinate> &coordinates);
|
||||
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
|
||||
std::shared_ptr<util::NodeBasedDynamicGraph>
|
||||
LoadNodeBasedGraph(std::unordered_set<NodeID> &barrier_nodes,
|
||||
std::unordered_set<NodeID> &traffic_lights,
|
||||
std::vector<QueryNode> &internal_to_external_node_map);
|
||||
std::vector<util::Coordinate> &coordinates,
|
||||
util::PackedVector<OSMNodeID> &osm_node_ids);
|
||||
|
||||
void WriteEdgeBasedGraph(const std::string &output_file_filename,
|
||||
const EdgeID max_edge_id,
|
||||
@@ -94,7 +95,7 @@ class Extractor
|
||||
// Writes compressed node based graph and its embedding into a file for osrm-partition to use.
|
||||
static void WriteCompressedNodeBasedGraph(const std::string &path,
|
||||
const util::NodeBasedDynamicGraph &graph,
|
||||
const std::vector<QueryNode> &externals);
|
||||
const std::vector<util::Coordinate> &coordiantes);
|
||||
|
||||
// globals persisting during the extraction process and the graph generation process
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/seralization.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/packed_vector.hpp"
|
||||
#include "util/serialization.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
@@ -13,6 +17,32 @@ namespace extractor
|
||||
namespace files
|
||||
{
|
||||
|
||||
// reads .osrm.nodes
|
||||
template<storage::Ownership Ownership>
|
||||
inline void readNodes(const boost::filesystem::path &path,
|
||||
typename util::ShM<util::Coordinate, Ownership>::vector &coordinates,
|
||||
util::detail::PackedVector<OSMNodeID, Ownership> &osm_node_ids)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
reader.DeserializeVector(coordinates);
|
||||
util::serialization::read(reader, osm_node_ids);
|
||||
}
|
||||
|
||||
// writes .osrm.nodes
|
||||
template<storage::Ownership Ownership>
|
||||
inline void writeNodes(const boost::filesystem::path &path,
|
||||
const typename util::ShM<util::Coordinate, Ownership>::vector &coordinates,
|
||||
const util::detail::PackedVector<OSMNodeID, Ownership> &osm_node_ids)
|
||||
{
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
writer.SerializeVector(coordinates);
|
||||
util::serialization::write(writer, osm_node_ids);
|
||||
}
|
||||
|
||||
// reads .osrm.cnbg_to_ebg
|
||||
inline void readNBGMapping(const boost::filesystem::path &path, std::vector<NBGToEBG> &mapping)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ class CoordinateExtractor
|
||||
public:
|
||||
CoordinateExtractor(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const std::vector<extractor::QueryNode> &node_coordinates);
|
||||
const std::vector<util::Coordinate> &node_coordinates);
|
||||
|
||||
/* Find a interpolated coordinate a long the compressed geometries. The desired coordinate
|
||||
* should be in a certain distance. This method is dedicated to find representative coordinates
|
||||
@@ -156,7 +156,7 @@ class CoordinateExtractor
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const std::vector<extractor::QueryNode> &node_coordinates;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
|
||||
double ComputeInterpolationFactor(const double desired_distance,
|
||||
const double distance_to_first,
|
||||
|
||||
@@ -40,7 +40,7 @@ class IntersectionGenerator
|
||||
IntersectionGenerator(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const RestrictionMap &restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const CompressedEdgeContainer &compressed_edge_container);
|
||||
|
||||
// For a source node `a` and a via edge `ab` creates an intersection at target `b`.
|
||||
@@ -112,7 +112,7 @@ class IntersectionGenerator
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const RestrictionMap &restriction_map;
|
||||
const std::unordered_set<NodeID> &barrier_nodes;
|
||||
const std::vector<QueryNode> &node_info_list;
|
||||
const std::vector<util::Coordinate> &coordinates;
|
||||
|
||||
// own state, used to find the correct coordinates along a road
|
||||
const CoordinateExtractor coordinate_extractor;
|
||||
|
||||
@@ -34,7 +34,7 @@ class IntersectionHandler
|
||||
{
|
||||
public:
|
||||
IntersectionHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table,
|
||||
const IntersectionGenerator &intersection_generator);
|
||||
@@ -51,7 +51,7 @@ class IntersectionHandler
|
||||
|
||||
protected:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const std::vector<QueryNode> &node_info_list;
|
||||
const std::vector<util::Coordinate> &coordinates;
|
||||
const util::NameTable &name_table;
|
||||
const SuffixTable &street_name_suffix_table;
|
||||
const IntersectionGenerator &intersection_generator;
|
||||
|
||||
@@ -43,7 +43,7 @@ class IntersectionNormalizer
|
||||
std::vector<IntersectionNormalizationOperation> performed_merges;
|
||||
};
|
||||
IntersectionNormalizer(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<extractor::QueryNode> &node_coordinates,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table,
|
||||
const IntersectionGenerator &intersection_generator);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
@@ -22,7 +23,6 @@ class NameTable;
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
struct QueryNode;
|
||||
class SuffixTable;
|
||||
|
||||
namespace guidance
|
||||
@@ -37,7 +37,7 @@ class MergableRoadDetector
|
||||
using MergableRoadData = IntersectionShapeData;
|
||||
|
||||
MergableRoadDetector(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_coordinates,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const IntersectionGenerator &intersection_generator,
|
||||
const CoordinateExtractor &coordinate_extractor,
|
||||
const util::NameTable &name_table,
|
||||
@@ -138,7 +138,7 @@ class MergableRoadDetector
|
||||
bool IsLinkRoad(const NodeID intersection_node, const MergableRoadData &road) const;
|
||||
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const std::vector<QueryNode> &node_coordinates;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
const IntersectionGenerator &intersection_generator;
|
||||
const CoordinateExtractor &coordinate_extractor;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class MotorwayHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table,
|
||||
const IntersectionGenerator &intersection_generator);
|
||||
|
||||
@@ -41,7 +41,7 @@ class RoundaboutHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
RoundaboutHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const CompressedEdgeContainer &compressed_edge_container,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table,
|
||||
|
||||
@@ -27,7 +27,7 @@ class SliproadHandler final : public IntersectionHandler
|
||||
public:
|
||||
SliproadHandler(const IntersectionGenerator &intersection_generator,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class SuppressModeHandler final : public IntersectionHandler
|
||||
public:
|
||||
SuppressModeHandler(const IntersectionGenerator &intersection_generator,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class TurnAnalysis
|
||||
{
|
||||
public:
|
||||
TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const RestrictionMap &restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const CompressedEdgeContainer &compressed_edge_container,
|
||||
|
||||
@@ -29,7 +29,7 @@ class TurnHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
TurnHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table,
|
||||
const IntersectionGenerator &intersection_generator);
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#ifndef OSRM_STORAGE_SERIALIZATION_HPP_
|
||||
#define OSRM_STORAGE_SERIALIZATION_HPP_
|
||||
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "extractor/extractor.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "storage/io.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/iostreams/seek.hpp>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace storage
|
||||
{
|
||||
namespace serialization
|
||||
{
|
||||
|
||||
// To make function calls consistent, this function returns the fixed number of properties
|
||||
inline std::size_t readPropertiesCount() { return 1; }
|
||||
|
||||
// Loads coordinates and OSM node IDs from .nodes files into memory
|
||||
// Needs to be called after readElementCount() to get the correct offset in the stream
|
||||
template <typename OSMNodeIDVectorT>
|
||||
void readNodes(io::FileReader &nodes_file,
|
||||
util::Coordinate *coordinate_list,
|
||||
OSMNodeIDVectorT &osmnodeid_list,
|
||||
const std::uint64_t number_of_coordinates)
|
||||
{
|
||||
BOOST_ASSERT(coordinate_list);
|
||||
extractor::QueryNode current_node;
|
||||
for (std::uint64_t i = 0; i < number_of_coordinates; ++i)
|
||||
{
|
||||
nodes_file.ReadInto(current_node);
|
||||
coordinate_list[i] = util::Coordinate(current_node.lon, current_node.lat);
|
||||
osmnodeid_list.push_back(current_node.node_id);
|
||||
BOOST_ASSERT(coordinate_list[i].IsValid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/packed_vector.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -57,21 +58,23 @@ template <typename BarrierOutIter, typename TrafficSignalsOutIter>
|
||||
NodeID loadNodesFromFile(storage::io::FileReader &file_reader,
|
||||
BarrierOutIter barriers,
|
||||
TrafficSignalsOutIter traffic_signals,
|
||||
std::vector<extractor::QueryNode> &node_array)
|
||||
std::vector<util::Coordinate> &coordinates,
|
||||
util::PackedVector<OSMNodeID> &osm_node_ids)
|
||||
{
|
||||
NodeID number_of_nodes = file_reader.ReadElementCount32();
|
||||
Log() << "Importing number_of_nodes new = " << number_of_nodes << " nodes ";
|
||||
|
||||
node_array.resize(number_of_nodes);
|
||||
coordinates.resize(number_of_nodes);
|
||||
osm_node_ids.reserve(number_of_nodes);
|
||||
|
||||
extractor::ExternalMemoryNode current_node;
|
||||
for (NodeID i = 0; i < number_of_nodes; ++i)
|
||||
{
|
||||
file_reader.ReadInto(¤t_node, 1);
|
||||
|
||||
node_array[i].lon = current_node.lon;
|
||||
node_array[i].lat = current_node.lat;
|
||||
node_array[i].node_id = current_node.node_id;
|
||||
coordinates[i].lon = current_node.lon;
|
||||
coordinates[i].lat = current_node.lat;
|
||||
osm_node_ids.push_back(current_node.node_id);
|
||||
|
||||
if (current_node.barrier)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "util/shared_memory_vector_wrapper.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
#include <cmath>
|
||||
@@ -13,7 +14,22 @@ namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, storage::Ownership Ownership> class PackedVector;
|
||||
}
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
template <typename T, storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader, detail::PackedVector<T, Ownership> &vec);
|
||||
|
||||
template <typename T, storage::Ownership Ownership>
|
||||
inline void write(storage::io::FileWriter &writer, const detail::PackedVector<T, Ownership> &vec);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
/**
|
||||
* Since OSM node IDs are (at the time of writing) not quite yet overflowing 32 bits, and
|
||||
* will predictably be containable within 33 bits for a long time, the following packs
|
||||
@@ -22,8 +38,7 @@ namespace util
|
||||
* NOTE: this type is templated for future use, but will require a slight refactor to
|
||||
* configure BITSIZE and ELEMSIZE
|
||||
*/
|
||||
template <typename T, storage::Ownership Ownership = storage::Ownership::Container>
|
||||
class PackedVector
|
||||
template <typename T, storage::Ownership Ownership> class PackedVector
|
||||
{
|
||||
static const constexpr std::size_t BITSIZE = 33;
|
||||
static const constexpr std::size_t ELEMSIZE = 64;
|
||||
@@ -80,7 +95,9 @@ class PackedVector
|
||||
num_elements++;
|
||||
}
|
||||
|
||||
T at(const std::size_t &a_index) const
|
||||
T operator[](const std::size_t index) const { return at(index); }
|
||||
|
||||
T at(const std::size_t a_index) const
|
||||
{
|
||||
BOOST_ASSERT(a_index < num_elements);
|
||||
|
||||
@@ -147,10 +164,16 @@ class PackedVector
|
||||
return std::floor(static_cast<double>(vec.capacity()) * ELEMSIZE / BITSIZE);
|
||||
}
|
||||
|
||||
friend void serialization::read<T, Ownership>(storage::io::FileReader &reader,
|
||||
detail::PackedVector<T, Ownership> &vec);
|
||||
|
||||
friend void serialization::write<T, Ownership>(storage::io::FileWriter &writer,
|
||||
const detail::PackedVector<T, Ownership> &vec);
|
||||
|
||||
private:
|
||||
typename util::ShM<std::uint64_t, Ownership>::vector vec;
|
||||
|
||||
std::size_t num_elements = 0;
|
||||
std::uint64_t num_elements = 0;
|
||||
|
||||
signed cursor = -1;
|
||||
|
||||
@@ -192,6 +215,10 @@ class PackedVector
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T> using PackedVector = detail::PackedVector<T, storage::Ownership::Container>;
|
||||
template <typename T> using PackedVectorView = detail::PackedVector<T, storage::Ownership::View>;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PACKED_VECTOR_HPP */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef OSMR_UTIL_SERIALIZATION_HPP
|
||||
#define OSMR_UTIL_SERIALIZATION_HPP
|
||||
|
||||
#include "util/packed_vector.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "storage/io.hpp"
|
||||
@@ -11,6 +12,21 @@ namespace util
|
||||
{
|
||||
namespace serialization
|
||||
{
|
||||
template <typename T, storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader,
|
||||
detail::PackedVector<T, Ownership> &vec)
|
||||
{
|
||||
vec.num_elements =reader.ReadOne<std::uint64_t>();
|
||||
reader.DeserializeVector(vec.vec);
|
||||
}
|
||||
|
||||
template <typename T, storage::Ownership Ownership>
|
||||
inline void write(storage::io::FileWriter &writer,
|
||||
const detail::PackedVector<T, Ownership> &vec)
|
||||
{
|
||||
writer.WriteOne(vec.num_elements);
|
||||
writer.SerializeVector(vec.vec);
|
||||
}
|
||||
|
||||
template <typename EdgeDataT, storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader,
|
||||
|
||||
@@ -53,16 +53,17 @@ namespace util
|
||||
// All coordinates are pojected first to Web Mercator before the bounding boxes
|
||||
// are computed, this means the internal distance metric doesn not represent meters!
|
||||
template <class EdgeDataT,
|
||||
class CoordinateListT = std::vector<Coordinate>,
|
||||
storage::Ownership Ownership = storage::Ownership::Container,
|
||||
std::uint32_t BRANCHING_FACTOR = 128,
|
||||
std::uint32_t LEAF_PAGE_SIZE = 4096>
|
||||
class StaticRTree
|
||||
{
|
||||
template <typename T> using Vector = typename ShM<T, Ownership>::vector;
|
||||
|
||||
public:
|
||||
using Rectangle = RectangleInt2D;
|
||||
using EdgeData = EdgeDataT;
|
||||
using CoordinateList = CoordinateListT;
|
||||
using CoordinateList = Vector<util::Coordinate>;
|
||||
|
||||
static_assert(LEAF_PAGE_SIZE >= sizeof(uint32_t) + sizeof(EdgeDataT), "page size is too small");
|
||||
static_assert(((LEAF_PAGE_SIZE - 1) & LEAF_PAGE_SIZE) == 0, "page size is not a power of 2");
|
||||
@@ -154,8 +155,8 @@ class StaticRTree
|
||||
Coordinate fixed_projected_coordinate;
|
||||
};
|
||||
|
||||
typename ShM<TreeNode, Ownership>::vector m_search_tree;
|
||||
const CoordinateListT &m_coordinate_list;
|
||||
Vector<TreeNode> m_search_tree;
|
||||
const Vector<Coordinate> &m_coordinate_list;
|
||||
|
||||
boost::iostreams::mapped_file_source m_leaves_region;
|
||||
// read-only view of leaves
|
||||
@@ -165,12 +166,11 @@ class StaticRTree
|
||||
StaticRTree(const StaticRTree &) = delete;
|
||||
StaticRTree &operator=(const StaticRTree &) = delete;
|
||||
|
||||
template <typename CoordinateT>
|
||||
// Construct a packed Hilbert-R-Tree with Kamel-Faloutsos algorithm [1]
|
||||
explicit StaticRTree(const std::vector<EdgeDataT> &input_data_vector,
|
||||
const std::string &tree_node_filename,
|
||||
const std::string &leaf_node_filename,
|
||||
const std::vector<CoordinateT> &coordinate_list)
|
||||
const Vector<Coordinate> &coordinate_list)
|
||||
: m_coordinate_list(coordinate_list)
|
||||
{
|
||||
const uint64_t element_count = input_data_vector.size();
|
||||
@@ -347,7 +347,7 @@ class StaticRTree
|
||||
|
||||
explicit StaticRTree(const boost::filesystem::path &node_file,
|
||||
const boost::filesystem::path &leaf_file,
|
||||
const CoordinateListT &coordinate_list)
|
||||
const Vector<Coordinate> &coordinate_list)
|
||||
: m_coordinate_list(coordinate_list)
|
||||
{
|
||||
storage::io::FileReader tree_node_file(node_file,
|
||||
@@ -364,7 +364,7 @@ class StaticRTree
|
||||
explicit StaticRTree(TreeNode *tree_node_ptr,
|
||||
const uint64_t number_of_nodes,
|
||||
const boost::filesystem::path &leaf_file,
|
||||
const CoordinateListT &coordinate_list)
|
||||
const Vector<Coordinate> &coordinate_list)
|
||||
: m_search_tree(tree_node_ptr, number_of_nodes), m_coordinate_list(coordinate_list)
|
||||
{
|
||||
MapLeafNodesFile(leaf_file);
|
||||
|
||||
Reference in New Issue
Block a user