osrm-backend/include/extractor/compressed_edge_container.hpp

86 lines
3.3 KiB
C++
Raw Permalink 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
#include "extractor/segment_data_container.hpp"
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>
namespace osrm::extractor
2016-01-05 10:51:13 -05:00
{
class CompressedEdgeContainer
{
public:
struct OnewayCompressedEdge
{
2016-03-03 08:26:13 -05:00
public:
NodeID node_id; // refers to an internal node-based-node
SegmentWeight weight; // the weight of the edge leading to this node
SegmentDuration duration; // the duration of the edge leading to this node
};
using OnewayEdgeBucket = std::vector<OnewayCompressedEdge>;
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,
const EdgeDuration duration1,
const EdgeDuration duration2,
// node-penalties can be added before/or after the traversal of an edge which
// depends on whether we traverse the link forwards or backwards.
const EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT,
const EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION);
2014-02-11 05:42:24 -05:00
void AddUncompressedEdge(const EdgeID edge_id,
const NodeID target_node,
const EdgeWeight weight,
const EdgeDuration duration);
void InitializeBothwayVector();
unsigned ZipEdges(const unsigned f_edge_pos, const unsigned r_edge_pos);
2014-02-11 05:42:24 -05:00
bool HasEntryForID(const EdgeID edge_id) const;
bool HasZippedEntryForForwardID(const EdgeID edge_id) const;
bool HasZippedEntryForReverseID(const EdgeID edge_id) const;
2013-11-25 13:05:58 -05:00
void PrintStatistics() const;
2014-02-11 05:42:24 -05:00
unsigned GetPositionForID(const EdgeID edge_id) const;
unsigned GetZippedPositionForForwardID(const EdgeID edge_id) const;
unsigned GetZippedPositionForReverseID(const EdgeID edge_id) const;
const OnewayEdgeBucket &GetBucketReference(const EdgeID edge_id) const;
bool IsTrivial(const EdgeID edge_id) const;
NodeID GetFirstEdgeTargetID(const EdgeID edge_id) const;
NodeID GetLastEdgeTargetID(const EdgeID edge_id) const;
NodeID GetLastEdgeSourceID(const EdgeID edge_id) const;
2013-11-25 13:05:58 -05:00
// Invalidates the internal storage
2017-03-09 17:44:56 -05:00
std::unique_ptr<SegmentDataContainer> ToSegmentData();
private:
SegmentWeight ClipWeight(const EdgeWeight weight);
SegmentDuration ClipDuration(const EdgeDuration duration);
int free_list_maximum = 0;
std::atomic_size_t clipped_weights{0};
std::atomic_size_t clipped_durations{0};
2013-11-25 13:05:58 -05:00
void IncreaseFreeList();
std::vector<OnewayEdgeBucket> m_compressed_oneway_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;
std::unordered_map<EdgeID, unsigned> m_forward_edge_id_to_zipped_index_map;
std::unordered_map<EdgeID, unsigned> m_reverse_edge_id_to_zipped_index_map;
2017-03-09 17:44:56 -05:00
std::unique_ptr<SegmentDataContainer> segment_data;
2013-11-25 13:05:58 -05:00
};
2022-12-20 12:00:11 -05:00
} // namespace osrm::extractor
2016-01-05 10:51:13 -05:00
2014-11-28 04:29:56 -05:00
#endif // GEOMETRY_COMPRESSOR_HPP_