osrm-backend/include/extractor/compressed_edge_container.hpp

59 lines
1.6 KiB
C++
Raw Normal View History

2014-11-28 04:29:56 -05:00
#ifndef GEOMETRY_COMPRESSOR_HPP_
#define GEOMETRY_COMPRESSOR_HPP_
2014-10-03 04:19:45 -04:00
2016-01-02 11:13:44 -05:00
#include "util/typedefs.hpp"
2013-11-25 13:05:58 -05:00
2014-05-09 12:40:07 -04:00
#include <unordered_map>
2013-11-25 13:05:58 -05:00
#include <string>
2013-11-25 13:05:58 -05:00
#include <vector>
2016-01-05 10:51:13 -05:00
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>;
2014-02-11 05:42:24 -05:00
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);
2014-02-11 05:42:24 -05:00
void AddUncompressedEdge(const EdgeID edgei_id,
const NodeID target_node,
const EdgeWeight weight);
2014-02-11 05:42:24 -05:00
bool HasEntryForID(const EdgeID edge_id) const;
2013-11-25 13:05:58 -05:00
void PrintStatistics() const;
void SerializeInternalVector(const std::string &path) const;
2014-02-11 05:42:24 -05:00
unsigned GetPositionForID(const EdgeID edge_id) const;
2016-01-05 06:04:04 -05:00
const EdgeBucket &GetBucketReference(const EdgeID edge_id) const;
NodeID GetFirstEdgeTargetID(const EdgeID edge_id) const;
NodeID GetLastEdgeSourceID(const EdgeID edge_id) const;
2013-11-25 13:05:58 -05:00
private:
int free_list_maximum = 0;
2013-11-25 13:05:58 -05:00
void IncreaseFreeList();
std::vector<EdgeBucket> m_compressed_geometries;
2013-11-25 13:05:58 -05:00
std::vector<unsigned> m_free_list;
2014-05-09 12:40:07 -04:00
std::unordered_map<EdgeID, unsigned> m_edge_id_to_list_index_map;
2013-11-25 13:05:58 -05:00
};
2016-01-05 10:51:13 -05:00
}
}
2014-11-28 04:29:56 -05:00
#endif // GEOMETRY_COMPRESSOR_HPP_