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
|
|
|
|
2014-05-09 13:50:16 -04: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
|
|
|
|
{
|
|
|
|
|
2015-06-24 13:55:36 -04:00
|
|
|
class CompressedEdgeContainer
|
2014-04-11 16:25:25 -04:00
|
|
|
{
|
|
|
|
public:
|
2016-07-22 12:23:54 -04:00
|
|
|
struct OnewayCompressedEdge
|
2016-01-29 20:52:20 -05:00
|
|
|
{
|
2016-03-03 08:26:13 -05:00
|
|
|
public:
|
2016-05-12 12:50:10 -04:00
|
|
|
NodeID node_id; // refers to an internal node-based-node
|
|
|
|
EdgeWeight weight; // the weight of the edge leading to this node
|
|
|
|
EdgeWeight duration; // the duration of the edge leading to this node
|
2016-01-29 20:52:20 -05:00
|
|
|
};
|
2016-07-22 12:23:54 -04:00
|
|
|
|
|
|
|
using OnewayEdgeBucket = std::vector<OnewayCompressedEdge>;
|
2014-02-11 05:42:24 -05:00
|
|
|
|
2015-06-24 13:55:36 -04:00
|
|
|
CompressedEdgeContainer();
|
2014-04-11 16:25:25 -04:00
|
|
|
void CompressEdge(const EdgeID surviving_edge_id,
|
|
|
|
const EdgeID removed_edge_id,
|
|
|
|
const NodeID via_node_id,
|
|
|
|
const NodeID target_node,
|
|
|
|
const EdgeWeight weight1,
|
2016-05-12 12:50:10 -04:00
|
|
|
const EdgeWeight weight2,
|
|
|
|
const EdgeWeight duration1,
|
|
|
|
const EdgeWeight duration2);
|
2014-02-11 05:42:24 -05:00
|
|
|
|
2016-05-12 12:50:10 -04:00
|
|
|
void AddUncompressedEdge(const EdgeID edge_id,
|
|
|
|
const NodeID target_node,
|
|
|
|
const EdgeWeight weight,
|
|
|
|
const EdgeWeight duration);
|
2016-01-29 20:52:20 -05:00
|
|
|
|
2016-07-22 12:23:54 -04:00
|
|
|
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;
|
2016-07-22 12:23:54 -04:00
|
|
|
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-04-11 16:25:25 -04:00
|
|
|
void SerializeInternalVector(const std::string &path) const;
|
2014-02-11 05:42:24 -05:00
|
|
|
unsigned GetPositionForID(const EdgeID edge_id) const;
|
2016-07-22 12:23:54 -04:00
|
|
|
unsigned GetZippedPositionForForwardID(const EdgeID edge_id) const;
|
|
|
|
unsigned GetZippedPositionForReverseID(const EdgeID edge_id) const;
|
|
|
|
const OnewayEdgeBucket &GetBucketReference(const EdgeID edge_id) const;
|
2016-04-29 03:48:13 -04:00
|
|
|
bool IsTrivial(const EdgeID edge_id) const;
|
2015-06-24 13:55:36 -04:00
|
|
|
NodeID GetFirstEdgeTargetID(const EdgeID edge_id) const;
|
2016-04-29 03:48:13 -04:00
|
|
|
NodeID GetLastEdgeTargetID(const EdgeID edge_id) const;
|
2015-06-24 13:55:36 -04:00
|
|
|
NodeID GetLastEdgeSourceID(const EdgeID edge_id) const;
|
2013-11-25 13:05:58 -05:00
|
|
|
|
2014-04-11 16:25:25 -04:00
|
|
|
private:
|
2015-03-05 05:30:52 -05:00
|
|
|
int free_list_maximum = 0;
|
2015-06-24 13:55:36 -04:00
|
|
|
|
2013-11-25 13:05:58 -05:00
|
|
|
void IncreaseFreeList();
|
2016-07-22 12:23:54 -04:00
|
|
|
std::vector<OnewayEdgeBucket> m_compressed_oneway_geometries;
|
2016-10-07 00:06:33 -04:00
|
|
|
std::vector<unsigned> m_compressed_geometry_index;
|
|
|
|
std::vector<NodeID> m_compressed_geometry_nodes;
|
|
|
|
std::vector<EdgeWeight> m_compressed_geometry_fwd_weights;
|
|
|
|
std::vector<EdgeWeight> m_compressed_geometry_rev_weights;
|
2016-05-12 12:50:10 -04:00
|
|
|
std::vector<EdgeWeight> m_compressed_geometry_fwd_durations;
|
|
|
|
std::vector<EdgeWeight> m_compressed_geometry_rev_durations;
|
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;
|
2016-07-22 12:23:54 -04:00
|
|
|
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;
|
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_
|