osrm-backend/include/extractor/compressed_edge_container.hpp
Daniel Patterson 49441fe204 Make forward/reverse weight/offset calculated at query time,
rather than being cached in the StaticRTree.  This means we
can freely apply traffic data and not have stale values lying
around.  It reduces the size of the RTree on disk, at the expense
of some additional data in RAM.
2016-03-03 10:49:12 -08:00

59 lines
1.6 KiB
C++

#ifndef GEOMETRY_COMPRESSOR_HPP_
#define GEOMETRY_COMPRESSOR_HPP_
#include "util/typedefs.hpp"
#include <unordered_map>
#include <string>
#include <vector>
namespace osrm
{
namespace extractor
{
class CompressedEdgeContainer
{
public:
struct CompressedEdge
{
public:
NodeID node_id; // refers to an internal node-based-node
EdgeWeight weight; // the weight of the edge leading to this node
};
using EdgeBucket = std::vector<CompressedEdge>;
CompressedEdgeContainer();
void CompressEdge(const EdgeID surviving_edge_id,
const EdgeID removed_edge_id,
const NodeID via_node_id,
const NodeID target_node,
const EdgeWeight weight1,
const EdgeWeight weight2);
void AddUncompressedEdge(const EdgeID edgei_id,
const NodeID target_node,
const EdgeWeight weight);
bool HasEntryForID(const EdgeID edge_id) const;
void PrintStatistics() const;
void SerializeInternalVector(const std::string &path) const;
unsigned GetPositionForID(const EdgeID edge_id) const;
const EdgeBucket &GetBucketReference(const EdgeID edge_id) const;
NodeID GetFirstEdgeTargetID(const EdgeID edge_id) const;
NodeID GetLastEdgeSourceID(const EdgeID edge_id) const;
private:
int free_list_maximum = 0;
void IncreaseFreeList();
std::vector<EdgeBucket> m_compressed_geometries;
std::vector<unsigned> m_free_list;
std::unordered_map<EdgeID, unsigned> m_edge_id_to_list_index_map;
};
}
}
#endif // GEOMETRY_COMPRESSOR_HPP_