Move ComponentID to EdgeBasedNodeDataContainer
This commit is contained in:
parent
373087d74f
commit
26702920b4
@ -68,9 +68,6 @@ class Contractor
|
|||||||
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
|
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
|
||||||
void WriteContractedGraph(unsigned number_of_edge_based_nodes,
|
void WriteContractedGraph(unsigned number_of_edge_based_nodes,
|
||||||
util::DeallocatingVector<QueryEdge> contracted_edge_list);
|
util::DeallocatingVector<QueryEdge> contracted_edge_list);
|
||||||
void FindComponents(unsigned max_edge_id,
|
|
||||||
const util::DeallocatingVector<extractor::EdgeBasedEdge> &edges,
|
|
||||||
std::vector<extractor::EdgeBasedNode> &nodes) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContractorConfig config;
|
ContractorConfig config;
|
||||||
|
@ -330,13 +330,20 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
util::vector_view<NameID> name_ids(name_id_list_ptr,
|
util::vector_view<NameID> name_ids(name_id_list_ptr,
|
||||||
layout.num_entries[storage::DataLayout::NAME_ID_LIST]);
|
layout.num_entries[storage::DataLayout::NAME_ID_LIST]);
|
||||||
|
|
||||||
|
const auto component_id_list_ptr =
|
||||||
|
layout.GetBlockPtr<ComponentID>(memory_ptr, storage::DataLayout::COMPONENT_ID_LIST);
|
||||||
|
util::vector_view<ComponentID> component_ids(
|
||||||
|
component_id_list_ptr, layout.num_entries[storage::DataLayout::COMPONENT_ID_LIST]);
|
||||||
|
|
||||||
const auto travel_mode_list_ptr = layout.GetBlockPtr<extractor::TravelMode>(
|
const auto travel_mode_list_ptr = layout.GetBlockPtr<extractor::TravelMode>(
|
||||||
memory_ptr, storage::DataLayout::TRAVEL_MODE_LIST);
|
memory_ptr, storage::DataLayout::TRAVEL_MODE_LIST);
|
||||||
util::vector_view<extractor::TravelMode> travel_modes(
|
util::vector_view<extractor::TravelMode> travel_modes(
|
||||||
travel_mode_list_ptr, layout.num_entries[storage::DataLayout::TRAVEL_MODE_LIST]);
|
travel_mode_list_ptr, layout.num_entries[storage::DataLayout::TRAVEL_MODE_LIST]);
|
||||||
|
|
||||||
edge_based_node_data = extractor::EdgeBasedNodeDataView(
|
edge_based_node_data = extractor::EdgeBasedNodeDataView(std::move(geometry_ids),
|
||||||
std::move(geometry_ids), std::move(name_ids), std::move(travel_modes));
|
std::move(name_ids),
|
||||||
|
std::move(component_ids),
|
||||||
|
std::move(travel_modes));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeEdgeInformationPointers(storage::DataLayout &layout, char *memory_ptr)
|
void InitializeEdgeInformationPointers(storage::DataLayout &layout, char *memory_ptr)
|
||||||
@ -742,6 +749,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
return edge_based_node_data.GetGeometryID(id);
|
return edge_based_node_data.GetGeometryID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComponentID GetComponentID(const NodeID id) const
|
||||||
|
{
|
||||||
|
return edge_based_node_data.GetComponentID(id);
|
||||||
|
}
|
||||||
|
|
||||||
extractor::TravelMode GetTravelMode(const NodeID id) const override final
|
extractor::TravelMode GetTravelMode(const NodeID id) const override final
|
||||||
{
|
{
|
||||||
return edge_based_node_data.GetTravelMode(id);
|
return edge_based_node_data.GetTravelMode(id);
|
||||||
|
@ -53,6 +53,8 @@ class BaseDataFacade
|
|||||||
|
|
||||||
virtual GeometryID GetGeometryIndex(const NodeID id) const = 0;
|
virtual GeometryID GetGeometryIndex(const NodeID id) const = 0;
|
||||||
|
|
||||||
|
virtual ComponentID GetComponentID(const NodeID id) const = 0;
|
||||||
|
|
||||||
virtual std::vector<NodeID> GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
virtual std::vector<NodeID> GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
||||||
|
|
||||||
virtual std::vector<NodeID> GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
virtual std::vector<NodeID> GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
||||||
|
@ -176,15 +176,15 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
auto results = rtree.Nearest(
|
auto results = rtree.Nearest(
|
||||||
input_coordinate,
|
input_coordinate,
|
||||||
[this, &has_big_component, &has_small_component](const CandidateSegment &segment) {
|
[this, &has_big_component, &has_small_component](const CandidateSegment &segment) {
|
||||||
auto use_segment = (!has_small_component ||
|
auto use_segment =
|
||||||
(!has_big_component && !segment.data.component.is_tiny));
|
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||||
const auto valid_edges = HasValidEdge(segment);
|
const auto valid_edges = HasValidEdge(segment);
|
||||||
|
|
||||||
if (valid_edges.first || valid_edges.second)
|
if (valid_edges.first || valid_edges.second)
|
||||||
{
|
{
|
||||||
has_big_component = has_big_component || !segment.data.component.is_tiny;
|
has_big_component = has_big_component || !IsTinyComponent(segment);
|
||||||
has_small_component = has_small_component || segment.data.component.is_tiny;
|
has_small_component = has_small_component || IsTinyComponent(segment);
|
||||||
}
|
}
|
||||||
use_directions = boolPairAnd(use_directions, valid_edges);
|
use_directions = boolPairAnd(use_directions, valid_edges);
|
||||||
return use_directions;
|
return use_directions;
|
||||||
@ -215,8 +215,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
auto results = rtree.Nearest(
|
auto results = rtree.Nearest(
|
||||||
input_coordinate,
|
input_coordinate,
|
||||||
[this, &has_big_component, &has_small_component](const CandidateSegment &segment) {
|
[this, &has_big_component, &has_small_component](const CandidateSegment &segment) {
|
||||||
auto use_segment = (!has_small_component ||
|
auto use_segment =
|
||||||
(!has_big_component && !segment.data.component.is_tiny));
|
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||||
if (!use_directions.first && !use_directions.second)
|
if (!use_directions.first && !use_directions.second)
|
||||||
return use_directions;
|
return use_directions;
|
||||||
@ -225,8 +225,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
if (valid_edges.first || valid_edges.second)
|
if (valid_edges.first || valid_edges.second)
|
||||||
{
|
{
|
||||||
|
|
||||||
has_big_component = has_big_component || !segment.data.component.is_tiny;
|
has_big_component = has_big_component || !IsTinyComponent(segment);
|
||||||
has_small_component = has_small_component || segment.data.component.is_tiny;
|
has_small_component = has_small_component || IsTinyComponent(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
use_directions = boolPairAnd(use_directions, valid_edges);
|
use_directions = boolPairAnd(use_directions, valid_edges);
|
||||||
@ -257,8 +257,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
input_coordinate,
|
input_coordinate,
|
||||||
[this, bearing, bearing_range, &has_big_component, &has_small_component](
|
[this, bearing, bearing_range, &has_big_component, &has_small_component](
|
||||||
const CandidateSegment &segment) {
|
const CandidateSegment &segment) {
|
||||||
auto use_segment = (!has_small_component ||
|
auto use_segment =
|
||||||
(!has_big_component && !segment.data.component.is_tiny));
|
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||||
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
||||||
|
|
||||||
@ -269,8 +269,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
HasValidEdge(segment));
|
HasValidEdge(segment));
|
||||||
if (use_directions.first || use_directions.second)
|
if (use_directions.first || use_directions.second)
|
||||||
{
|
{
|
||||||
has_big_component = has_big_component || !segment.data.component.is_tiny;
|
has_big_component = has_big_component || !IsTinyComponent(segment);
|
||||||
has_small_component = has_small_component || segment.data.component.is_tiny;
|
has_small_component = has_small_component || IsTinyComponent(segment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,8 +304,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
input_coordinate,
|
input_coordinate,
|
||||||
[this, bearing, bearing_range, &has_big_component, &has_small_component](
|
[this, bearing, bearing_range, &has_big_component, &has_small_component](
|
||||||
const CandidateSegment &segment) {
|
const CandidateSegment &segment) {
|
||||||
auto use_segment = (!has_small_component ||
|
auto use_segment =
|
||||||
(!has_big_component && !segment.data.component.is_tiny));
|
(!has_small_component || (!has_big_component && !IsTinyComponent(segment)));
|
||||||
auto use_directions = std::make_pair(use_segment, use_segment);
|
auto use_directions = std::make_pair(use_segment, use_segment);
|
||||||
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
use_directions = boolPairAnd(use_directions, HasValidEdge(segment));
|
||||||
|
|
||||||
@ -316,8 +316,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
HasValidEdge(segment));
|
HasValidEdge(segment));
|
||||||
if (use_directions.first || use_directions.second)
|
if (use_directions.first || use_directions.second)
|
||||||
{
|
{
|
||||||
has_big_component = has_big_component || !segment.data.component.is_tiny;
|
has_big_component = has_big_component || !IsTinyComponent(segment);
|
||||||
has_small_component = has_small_component || segment.data.component.is_tiny;
|
has_small_component = has_small_component || IsTinyComponent(segment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,6 +379,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
datafacade.GetGeometryIndex(data.forward_segment_id.id).id ==
|
datafacade.GetGeometryIndex(data.forward_segment_id.id).id ==
|
||||||
datafacade.GetGeometryIndex(data.reverse_segment_id.id).id);
|
datafacade.GetGeometryIndex(data.reverse_segment_id.id).id);
|
||||||
const auto geometry_id = datafacade.GetGeometryIndex(data.forward_segment_id.id).id;
|
const auto geometry_id = datafacade.GetGeometryIndex(data.forward_segment_id.id).id;
|
||||||
|
const auto component_id = datafacade.GetComponentID(data.forward_segment_id.id);
|
||||||
|
|
||||||
const std::vector<EdgeWeight> forward_weight_vector =
|
const std::vector<EdgeWeight> forward_weight_vector =
|
||||||
datafacade.GetUncompressedForwardWeights(geometry_id);
|
datafacade.GetUncompressedForwardWeights(geometry_id);
|
||||||
@ -437,6 +438,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
reverse_weight_vector.begin(), reverse_weight_vector.end() - data.fwd_segment_position);
|
reverse_weight_vector.begin(), reverse_weight_vector.end() - data.fwd_segment_position);
|
||||||
|
|
||||||
auto transformed = PhantomNodeWithDistance{PhantomNode{data,
|
auto transformed = PhantomNodeWithDistance{PhantomNode{data,
|
||||||
|
component_id,
|
||||||
forward_weight,
|
forward_weight,
|
||||||
reverse_weight,
|
reverse_weight,
|
||||||
forward_weight_offset,
|
forward_weight_offset,
|
||||||
@ -535,6 +537,14 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
return std::make_pair(forward_edge_valid, reverse_edge_valid);
|
return std::make_pair(forward_edge_valid, reverse_edge_valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsTinyComponent(const CandidateSegment &segment) const
|
||||||
|
{
|
||||||
|
const auto &data = segment.data;
|
||||||
|
BOOST_ASSERT(data.forward_segment_id.enabled);
|
||||||
|
BOOST_ASSERT(data.forward_segment_id.id != SPECIAL_NODEID);
|
||||||
|
return datafacade.GetComponentID(data.forward_segment_id.id).is_tiny;
|
||||||
|
}
|
||||||
|
|
||||||
const RTreeT &rtree;
|
const RTreeT &rtree;
|
||||||
const CoordinateList &coordinates;
|
const CoordinateList &coordinates;
|
||||||
DataFacadeT &datafacade;
|
DataFacadeT &datafacade;
|
||||||
|
@ -51,8 +51,7 @@ struct PhantomNode
|
|||||||
reverse_segment_id{SPECIAL_SEGMENTID, false}, forward_weight(INVALID_EDGE_WEIGHT),
|
reverse_segment_id{SPECIAL_SEGMENTID, false}, forward_weight(INVALID_EDGE_WEIGHT),
|
||||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
|
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
|
||||||
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
|
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
|
||||||
forward_duration_offset(0), reverse_duration_offset(0),
|
forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0),
|
||||||
component{INVALID_COMPONENTID, false}, fwd_segment_position(0),
|
|
||||||
is_valid_forward_source{false}, is_valid_forward_target{false},
|
is_valid_forward_source{false}, is_valid_forward_target{false},
|
||||||
is_valid_reverse_source{false}, is_valid_reverse_target{false}, unused{0}
|
is_valid_reverse_source{false}, is_valid_reverse_target{false}, unused{0}
|
||||||
{
|
{
|
||||||
@ -123,6 +122,7 @@ struct PhantomNode
|
|||||||
|
|
||||||
template <class OtherT>
|
template <class OtherT>
|
||||||
explicit PhantomNode(const OtherT &other,
|
explicit PhantomNode(const OtherT &other,
|
||||||
|
ComponentID component,
|
||||||
EdgeWeight forward_weight,
|
EdgeWeight forward_weight,
|
||||||
EdgeWeight reverse_weight,
|
EdgeWeight reverse_weight,
|
||||||
EdgeWeight forward_weight_offset,
|
EdgeWeight forward_weight_offset,
|
||||||
@ -143,7 +143,7 @@ struct PhantomNode
|
|||||||
reverse_weight_offset{reverse_weight_offset}, forward_duration{forward_duration},
|
reverse_weight_offset{reverse_weight_offset}, forward_duration{forward_duration},
|
||||||
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
|
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
|
||||||
reverse_duration_offset{reverse_duration_offset},
|
reverse_duration_offset{reverse_duration_offset},
|
||||||
component{other.component.id, other.component.is_tiny}, location{location},
|
component{component.id, component.is_tiny}, location{location},
|
||||||
input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
|
input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
|
||||||
is_valid_forward_source{is_valid_forward_source},
|
is_valid_forward_source{is_valid_forward_source},
|
||||||
is_valid_forward_target{is_valid_forward_target},
|
is_valid_forward_target{is_valid_forward_target},
|
||||||
@ -162,12 +162,7 @@ struct PhantomNode
|
|||||||
EdgeWeight reverse_duration;
|
EdgeWeight reverse_duration;
|
||||||
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
||||||
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
||||||
struct ComponentType
|
ComponentID component;
|
||||||
{
|
|
||||||
std::uint32_t id : 31;
|
|
||||||
std::uint32_t is_tiny : 1;
|
|
||||||
} component;
|
|
||||||
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to be 4 bytes big");
|
|
||||||
|
|
||||||
util::Coordinate location;
|
util::Coordinate location;
|
||||||
util::Coordinate input_location;
|
util::Coordinate input_location;
|
||||||
|
@ -84,7 +84,6 @@ class EdgeBasedGraphFactory
|
|||||||
guidance::LaneDescriptionMap &lane_description_map);
|
guidance::LaneDescriptionMap &lane_description_map);
|
||||||
|
|
||||||
void Run(ScriptingEnvironment &scripting_environment,
|
void Run(ScriptingEnvironment &scripting_environment,
|
||||||
const std::string &nodes_data_filename,
|
|
||||||
const std::string &turn_data_filename,
|
const std::string &turn_data_filename,
|
||||||
const std::string &turn_lane_data_filename,
|
const std::string &turn_lane_data_filename,
|
||||||
const std::string &turn_weight_penalties_filename,
|
const std::string &turn_weight_penalties_filename,
|
||||||
@ -94,7 +93,8 @@ class EdgeBasedGraphFactory
|
|||||||
|
|
||||||
// The following get access functions destroy the content in the factory
|
// The following get access functions destroy the content in the factory
|
||||||
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
|
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
|
||||||
void GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes);
|
void GetEdgeBasedNodes(EdgeBasedNodeDataExternalContainer &ebg_node_data_container);
|
||||||
|
void GetNodeBasedEdges(std::vector<EdgeBasedNode> &nodes);
|
||||||
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
|
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
|
||||||
void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights);
|
void GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &output_node_weights);
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class EdgeBasedGraphFactory
|
|||||||
|
|
||||||
unsigned RenumberEdges();
|
unsigned RenumberEdges();
|
||||||
|
|
||||||
std::vector<NBGToEBG> GenerateEdgeExpandedNodes(const std::string &node_data_filename);
|
std::vector<NBGToEBG> GenerateEdgeExpandedNodes();
|
||||||
|
|
||||||
void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
|
void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
|
||||||
const std::string &original_edge_data_filename,
|
const std::string &original_edge_data_filename,
|
||||||
|
@ -22,7 +22,6 @@ struct EdgeBasedNode
|
|||||||
EdgeBasedNode()
|
EdgeBasedNode()
|
||||||
: forward_segment_id{SPECIAL_SEGMENTID, false},
|
: forward_segment_id{SPECIAL_SEGMENTID, false},
|
||||||
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
|
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
|
||||||
component{INVALID_COMPONENTID, false},
|
|
||||||
fwd_segment_position(std::numeric_limits<unsigned short>::max())
|
fwd_segment_position(std::numeric_limits<unsigned short>::max())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -31,12 +30,9 @@ struct EdgeBasedNode
|
|||||||
const SegmentID reverse_segment_id_,
|
const SegmentID reverse_segment_id_,
|
||||||
NodeID u,
|
NodeID u,
|
||||||
NodeID v,
|
NodeID v,
|
||||||
bool is_tiny_component,
|
|
||||||
unsigned component_id,
|
|
||||||
unsigned short fwd_segment_position)
|
unsigned short fwd_segment_position)
|
||||||
: forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u),
|
: forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u),
|
||||||
v(v), component{component_id, is_tiny_component},
|
v(v), fwd_segment_position(fwd_segment_position)
|
||||||
fwd_segment_position(fwd_segment_position)
|
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled);
|
BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled);
|
||||||
}
|
}
|
||||||
@ -45,12 +41,6 @@ struct EdgeBasedNode
|
|||||||
SegmentID reverse_segment_id; // edge-based graph node ID in reverse direction (v->u if exists)
|
SegmentID reverse_segment_id; // edge-based graph node ID in reverse direction (v->u if exists)
|
||||||
NodeID u; // node-based graph node ID of the start node
|
NodeID u; // node-based graph node ID of the start node
|
||||||
NodeID v; // node-based graph node ID of the target node
|
NodeID v; // node-based graph node ID of the target node
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned id : 31;
|
|
||||||
bool is_tiny : 1;
|
|
||||||
} component;
|
|
||||||
unsigned short fwd_segment_position; // segment id in a compressed geometry
|
unsigned short fwd_segment_position; // segment id in a compressed geometry
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ class Extractor
|
|||||||
BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
||||||
std::vector<util::Coordinate> &coordinates,
|
std::vector<util::Coordinate> &coordinates,
|
||||||
extractor::PackedOSMIDs &osm_node_ids,
|
extractor::PackedOSMIDs &osm_node_ids,
|
||||||
|
EdgeBasedNodeDataExternalContainer &ebg_node_data_container,
|
||||||
std::vector<EdgeBasedNode> &node_based_edge_list,
|
std::vector<EdgeBasedNode> &node_based_edge_list,
|
||||||
std::vector<bool> &node_is_startpoint,
|
std::vector<bool> &node_is_startpoint,
|
||||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||||
@ -73,7 +74,7 @@ class Extractor
|
|||||||
const ProfileProperties &properties) const;
|
const ProfileProperties &properties) const;
|
||||||
void FindComponents(unsigned max_edge_id,
|
void FindComponents(unsigned max_edge_id,
|
||||||
const util::DeallocatingVector<EdgeBasedEdge> &edges,
|
const util::DeallocatingVector<EdgeBasedEdge> &edges,
|
||||||
std::vector<EdgeBasedNode> &nodes) const;
|
EdgeBasedNodeDataExternalContainer &nodes) const;
|
||||||
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||||
std::vector<bool> node_is_startpoint,
|
std::vector<bool> node_is_startpoint,
|
||||||
const std::vector<util::Coordinate> &coordinates);
|
const std::vector<util::Coordinate> &coordinates);
|
||||||
|
@ -38,15 +38,16 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
|||||||
EdgeBasedNodeDataContainerImpl() = default;
|
EdgeBasedNodeDataContainerImpl() = default;
|
||||||
|
|
||||||
EdgeBasedNodeDataContainerImpl(std::size_t size)
|
EdgeBasedNodeDataContainerImpl(std::size_t size)
|
||||||
: geometry_ids(size), name_ids(size), travel_modes(size)
|
: geometry_ids(size), name_ids(size), component_ids(size), travel_modes(size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeBasedNodeDataContainerImpl(Vector<GeometryID> geometry_ids,
|
EdgeBasedNodeDataContainerImpl(Vector<GeometryID> geometry_ids,
|
||||||
Vector<NameID> name_ids,
|
Vector<NameID> name_ids,
|
||||||
|
Vector<ComponentID> component_ids,
|
||||||
Vector<TravelMode> travel_modes)
|
Vector<TravelMode> travel_modes)
|
||||||
: geometry_ids(std::move(geometry_ids)), name_ids(std::move(name_ids)),
|
: geometry_ids(std::move(geometry_ids)), name_ids(std::move(name_ids)),
|
||||||
travel_modes(std::move(travel_modes))
|
component_ids(std::move(component_ids)), travel_modes(std::move(travel_modes))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
|||||||
|
|
||||||
NameID GetNameID(const NodeID node_id) const { return name_ids[node_id]; }
|
NameID GetNameID(const NodeID node_id) const { return name_ids[node_id]; }
|
||||||
|
|
||||||
|
ComponentID GetComponentID(const NodeID node_id) const { return component_ids[node_id]; }
|
||||||
|
|
||||||
// Used by EdgeBasedGraphFactory to fill data structure
|
// Used by EdgeBasedGraphFactory to fill data structure
|
||||||
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
||||||
void SetData(NodeID node_id, GeometryID geometry_id, NameID name_id, TravelMode travel_mode)
|
void SetData(NodeID node_id, GeometryID geometry_id, NameID name_id, TravelMode travel_mode)
|
||||||
@ -65,6 +68,13 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
|||||||
travel_modes[node_id] = travel_mode;
|
travel_modes[node_id] = travel_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by EdgeBasedGraphFactory to fill data structure
|
||||||
|
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
||||||
|
void SetData(NodeID node_id, ComponentID component_id)
|
||||||
|
{
|
||||||
|
component_ids[node_id] = component_id;
|
||||||
|
}
|
||||||
|
|
||||||
friend void serialization::read<Ownership>(storage::io::FileReader &reader,
|
friend void serialization::read<Ownership>(storage::io::FileReader &reader,
|
||||||
EdgeBasedNodeDataContainerImpl &ebn_data_container);
|
EdgeBasedNodeDataContainerImpl &ebn_data_container);
|
||||||
friend void
|
friend void
|
||||||
@ -74,6 +84,7 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
|||||||
private:
|
private:
|
||||||
Vector<GeometryID> geometry_ids;
|
Vector<GeometryID> geometry_ids;
|
||||||
Vector<NameID> name_ids;
|
Vector<NameID> name_ids;
|
||||||
|
Vector<ComponentID> component_ids;
|
||||||
Vector<TravelMode> travel_modes;
|
Vector<TravelMode> travel_modes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ inline void read(storage::io::FileReader &reader,
|
|||||||
{
|
{
|
||||||
storage::serialization::read(reader, node_data_container.geometry_ids);
|
storage::serialization::read(reader, node_data_container.geometry_ids);
|
||||||
storage::serialization::read(reader, node_data_container.name_ids);
|
storage::serialization::read(reader, node_data_container.name_ids);
|
||||||
|
storage::serialization::read(reader, node_data_container.component_ids);
|
||||||
storage::serialization::read(reader, node_data_container.travel_modes);
|
storage::serialization::read(reader, node_data_container.travel_modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ inline void write(storage::io::FileWriter &writer,
|
|||||||
{
|
{
|
||||||
storage::serialization::write(writer, node_data_container.geometry_ids);
|
storage::serialization::write(writer, node_data_container.geometry_ids);
|
||||||
storage::serialization::write(writer, node_data_container.name_ids);
|
storage::serialization::write(writer, node_data_container.name_ids);
|
||||||
|
storage::serialization::write(writer, node_data_container.component_ids);
|
||||||
storage::serialization::write(writer, node_data_container.travel_modes);
|
storage::serialization::write(writer, node_data_container.travel_modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ const constexpr char CANARY[4] = {'O', 'S', 'R', 'M'};
|
|||||||
const constexpr char *block_id_to_name[] = {"NAME_CHAR_DATA",
|
const constexpr char *block_id_to_name[] = {"NAME_CHAR_DATA",
|
||||||
"GEOMETRY_ID_LIST",
|
"GEOMETRY_ID_LIST",
|
||||||
"NAME_ID_LIST",
|
"NAME_ID_LIST",
|
||||||
|
"COMPONENT_ID_LIST",
|
||||||
"TRAVEL_MODE_LIST",
|
"TRAVEL_MODE_LIST",
|
||||||
"CH_GRAPH_NODE_LIST",
|
"CH_GRAPH_NODE_LIST",
|
||||||
"CH_GRAPH_EDGE_LIST",
|
"CH_GRAPH_EDGE_LIST",
|
||||||
@ -74,6 +75,7 @@ struct DataLayout
|
|||||||
NAME_CHAR_DATA = 0,
|
NAME_CHAR_DATA = 0,
|
||||||
GEOMETRY_ID_LIST,
|
GEOMETRY_ID_LIST,
|
||||||
NAME_ID_LIST,
|
NAME_ID_LIST,
|
||||||
|
COMPONENT_ID_LIST,
|
||||||
TRAVEL_MODE_LIST,
|
TRAVEL_MODE_LIST,
|
||||||
CH_GRAPH_NODE_LIST,
|
CH_GRAPH_NODE_LIST,
|
||||||
CH_GRAPH_EDGE_LIST,
|
CH_GRAPH_EDGE_LIST,
|
||||||
|
@ -147,4 +147,11 @@ struct GeometryID
|
|||||||
|
|
||||||
static_assert(sizeof(SegmentID) == 4, "SegmentID needs to be 4 bytes big");
|
static_assert(sizeof(SegmentID) == 4, "SegmentID needs to be 4 bytes big");
|
||||||
|
|
||||||
|
// Strongly connected component ID of an edge-based node
|
||||||
|
struct ComponentID
|
||||||
|
{
|
||||||
|
std::uint32_t id : 31;
|
||||||
|
std::uint32_t is_tiny : 1;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* TYPEDEFS_H */
|
#endif /* TYPEDEFS_H */
|
||||||
|
@ -495,6 +495,7 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
|
|||||||
reverse_datasource_vector[reverse_datasource_vector.size() -
|
reverse_datasource_vector[reverse_datasource_vector.size() -
|
||||||
edge.fwd_segment_position - 1];
|
edge.fwd_segment_position - 1];
|
||||||
|
|
||||||
|
const auto component_id = facade.GetComponentID(edge.forward_segment_id.id);
|
||||||
const auto name_id = facade.GetNameIndex(edge.forward_segment_id.id);
|
const auto name_id = facade.GetNameIndex(edge.forward_segment_id.id);
|
||||||
auto name = facade.GetNameForID(name_id);
|
auto name = facade.GetNameForID(name_id);
|
||||||
|
|
||||||
@ -512,6 +513,7 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
|
|||||||
|
|
||||||
const auto encode_tile_line = [&line_layer_writer,
|
const auto encode_tile_line = [&line_layer_writer,
|
||||||
&edge,
|
&edge,
|
||||||
|
&component_id,
|
||||||
&id,
|
&id,
|
||||||
&max_datasource_id,
|
&max_datasource_id,
|
||||||
&used_line_ints](const FixedLine &tile_line,
|
&used_line_ints](const FixedLine &tile_line,
|
||||||
@ -549,7 +551,7 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
|
|||||||
std::min(speed_kmh, 127u)); // save the speed value, capped at 127
|
std::min(speed_kmh, 127u)); // save the speed value, capped at 127
|
||||||
field.add_element(1); // "is_small" tag key offset
|
field.add_element(1); // "is_small" tag key offset
|
||||||
field.add_element(128 +
|
field.add_element(128 +
|
||||||
(edge.component.is_tiny ? 0 : 1)); // is_small feature
|
(component_id.is_tiny ? 0 : 1)); // is_small feature
|
||||||
field.add_element(2); // "datasource" tag key offset
|
field.add_element(2); // "datasource" tag key offset
|
||||||
field.add_element(130 + datasource); // datasource value offset
|
field.add_element(130 + datasource); // datasource value offset
|
||||||
field.add_element(3); // "weight" tag key offset
|
field.add_element(3); // "weight" tag key offset
|
||||||
|
@ -66,7 +66,14 @@ void EdgeBasedGraphFactory::GetEdgeBasedEdges(
|
|||||||
swap(m_edge_based_edge_list, output_edge_list);
|
swap(m_edge_based_edge_list, output_edge_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EdgeBasedGraphFactory::GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes)
|
void EdgeBasedGraphFactory::GetEdgeBasedNodes(
|
||||||
|
EdgeBasedNodeDataExternalContainer &ebg_node_data_container)
|
||||||
|
{
|
||||||
|
using std::swap; // Koenig swap
|
||||||
|
swap(ebg_node_data_container, m_ebg_node_data_container);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EdgeBasedGraphFactory::GetNodeBasedEdges(std::vector<EdgeBasedNode> &nodes)
|
||||||
{
|
{
|
||||||
using std::swap; // Koenig swap
|
using std::swap; // Koenig swap
|
||||||
swap(nodes, m_edge_based_node_list);
|
swap(nodes, m_edge_based_node_list);
|
||||||
@ -163,8 +170,6 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
|||||||
edge_id_to_segment_id(reverse_data.edge_id),
|
edge_id_to_segment_id(reverse_data.edge_id),
|
||||||
current_edge_source_coordinate_id,
|
current_edge_source_coordinate_id,
|
||||||
current_edge_target_coordinate_id,
|
current_edge_target_coordinate_id,
|
||||||
false,
|
|
||||||
INVALID_COMPONENTID,
|
|
||||||
i);
|
i);
|
||||||
|
|
||||||
m_edge_based_node_is_startpoint.push_back(forward_data.startpoint ||
|
m_edge_based_node_is_startpoint.push_back(forward_data.startpoint ||
|
||||||
@ -178,7 +183,6 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||||
const std::string &node_data_filename,
|
|
||||||
const std::string &turn_data_filename,
|
const std::string &turn_data_filename,
|
||||||
const std::string &turn_lane_data_filename,
|
const std::string &turn_lane_data_filename,
|
||||||
const std::string &turn_weight_penalties_filename,
|
const std::string &turn_weight_penalties_filename,
|
||||||
@ -192,7 +196,7 @@ void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
|||||||
|
|
||||||
TIMER_START(generate_nodes);
|
TIMER_START(generate_nodes);
|
||||||
{
|
{
|
||||||
auto mapping = GenerateEdgeExpandedNodes(node_data_filename);
|
auto mapping = GenerateEdgeExpandedNodes();
|
||||||
files::writeNBGMapping(cnbg_ebg_mapping_path, mapping);
|
files::writeNBGMapping(cnbg_ebg_mapping_path, mapping);
|
||||||
}
|
}
|
||||||
TIMER_STOP(generate_nodes);
|
TIMER_STOP(generate_nodes);
|
||||||
@ -249,12 +253,11 @@ unsigned EdgeBasedGraphFactory::RenumberEdges()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates the nodes in the edge expanded graph from edges in the node-based graph.
|
/// Creates the nodes in the edge expanded graph from edges in the node-based graph.
|
||||||
std::vector<NBGToEBG>
|
std::vector<NBGToEBG> EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
|
||||||
EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const std::string &node_data_filename)
|
|
||||||
{
|
{
|
||||||
std::vector<NBGToEBG> mapping;
|
std::vector<NBGToEBG> mapping;
|
||||||
|
|
||||||
// TODO: make m_ebg_node_data_container local
|
// Allocate memory for edge-based nodes
|
||||||
m_ebg_node_data_container = EdgeBasedNodeDataExternalContainer(m_max_edge_id + 1);
|
m_ebg_node_data_container = EdgeBasedNodeDataExternalContainer(m_max_edge_id + 1);
|
||||||
|
|
||||||
util::Log() << "Generating edge expanded nodes ... ";
|
util::Log() << "Generating edge expanded nodes ... ";
|
||||||
@ -301,50 +304,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const std::string &node_data_fi
|
|||||||
BOOST_ASSERT(m_edge_based_node_list.size() == m_edge_based_node_is_startpoint.size());
|
BOOST_ASSERT(m_edge_based_node_list.size() == m_edge_based_node_is_startpoint.size());
|
||||||
BOOST_ASSERT(m_max_edge_id + 1 == m_edge_based_node_weights.size());
|
BOOST_ASSERT(m_max_edge_id + 1 == m_edge_based_node_weights.size());
|
||||||
|
|
||||||
{
|
|
||||||
// TODO: refactor saving edge-based node data with InsertEdgeBasedNode
|
|
||||||
for (const auto nbg_node_id : util::irange(0u, m_node_based_graph->GetNumberOfNodes()))
|
|
||||||
{
|
|
||||||
for (const auto nbg_edge_id : m_node_based_graph->GetAdjacentEdgeRange(nbg_node_id))
|
|
||||||
{
|
|
||||||
const auto &nbg_edge_data = m_node_based_graph->GetEdgeData(nbg_edge_id);
|
|
||||||
|
|
||||||
if (nbg_edge_data.edge_id == SPECIAL_EDGEID)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const bool is_encoded_forwards =
|
|
||||||
m_compressed_edge_container.HasZippedEntryForForwardID(nbg_edge_id);
|
|
||||||
const bool is_encoded_backwards =
|
|
||||||
m_compressed_edge_container.HasZippedEntryForReverseID(nbg_edge_id);
|
|
||||||
|
|
||||||
BOOST_ASSERT(is_encoded_forwards || is_encoded_backwards);
|
|
||||||
|
|
||||||
// auto geometry_id =
|
|
||||||
// is_encoded_forwards
|
|
||||||
// ? m_compressed_edge_container.GetZippedPositionForForwardID(nbg_edge_id)
|
|
||||||
// : is_encoded_backwards
|
|
||||||
// ? m_compressed_edge_container.GetZippedPositionForReverseID(
|
|
||||||
// nbg_edge_id)
|
|
||||||
// : SPECIAL_GEOMETRYID;
|
|
||||||
|
|
||||||
BOOST_ASSERT(m_ebg_node_data_container.GetNameID(nbg_edge_data.edge_id) ==
|
|
||||||
nbg_edge_data.name_id);
|
|
||||||
BOOST_ASSERT(m_ebg_node_data_container.GetTravelMode(nbg_edge_data.edge_id) ==
|
|
||||||
nbg_edge_data.travel_mode);
|
|
||||||
|
|
||||||
// m_ebg_node_data_container.SetData(nbg_edge_data.edge_id,
|
|
||||||
// GeometryID{geometry_id, is_encoded_forwards},
|
|
||||||
// nbg_edge_data.name_id,
|
|
||||||
// nbg_edge_data.travel_mode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
util::Log() << "Generated " << m_edge_based_node_list.size() << " nodes in edge-expanded graph";
|
util::Log() << "Generated " << m_edge_based_node_list.size() << " nodes in edge-expanded graph";
|
||||||
|
|
||||||
files::writeNodeData(node_data_filename, m_ebg_node_data_container);
|
|
||||||
m_ebg_node_data_container = EdgeBasedNodeDataExternalContainer();
|
|
||||||
|
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,8 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
|||||||
|
|
||||||
TIMER_START(expansion);
|
TIMER_START(expansion);
|
||||||
|
|
||||||
std::vector<EdgeBasedNode> edge_based_node_list;
|
EdgeBasedNodeDataExternalContainer edge_based_nodes_container;
|
||||||
|
std::vector<EdgeBasedNode> node_based_edges_list;
|
||||||
util::DeallocatingVector<EdgeBasedEdge> edge_based_edge_list;
|
util::DeallocatingVector<EdgeBasedEdge> edge_based_edge_list;
|
||||||
std::vector<bool> node_is_startpoint;
|
std::vector<bool> node_is_startpoint;
|
||||||
std::vector<EdgeWeight> edge_based_node_weights;
|
std::vector<EdgeWeight> edge_based_node_weights;
|
||||||
@ -140,7 +141,8 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
|||||||
auto graph_size = BuildEdgeExpandedGraph(scripting_environment,
|
auto graph_size = BuildEdgeExpandedGraph(scripting_environment,
|
||||||
coordinates,
|
coordinates,
|
||||||
osm_node_ids,
|
osm_node_ids,
|
||||||
edge_based_node_list,
|
edge_based_nodes_container,
|
||||||
|
node_based_edges_list,
|
||||||
node_is_startpoint,
|
node_is_startpoint,
|
||||||
edge_based_node_weights,
|
edge_based_node_weights,
|
||||||
edge_based_edge_list,
|
edge_based_edge_list,
|
||||||
@ -163,16 +165,17 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
|||||||
util::Log() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) << ")";
|
util::Log() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) << ")";
|
||||||
|
|
||||||
util::Log() << "Computing strictly connected components ...";
|
util::Log() << "Computing strictly connected components ...";
|
||||||
FindComponents(max_edge_id, edge_based_edge_list, edge_based_node_list);
|
FindComponents(max_edge_id, edge_based_edge_list, edge_based_nodes_container);
|
||||||
|
|
||||||
util::Log() << "Building r-tree ...";
|
util::Log() << "Building r-tree ...";
|
||||||
TIMER_START(rtree);
|
TIMER_START(rtree);
|
||||||
BuildRTree(std::move(edge_based_node_list), std::move(node_is_startpoint), coordinates);
|
BuildRTree(std::move(node_based_edges_list), std::move(node_is_startpoint), coordinates);
|
||||||
|
|
||||||
TIMER_STOP(rtree);
|
TIMER_STOP(rtree);
|
||||||
|
|
||||||
util::Log() << "Writing node map ...";
|
util::Log() << "Writing nodes for nodes-based and edges-based graphs ...";
|
||||||
files::writeNodes(config.node_output_path, coordinates, osm_node_ids);
|
files::writeNodes(config.node_output_path, coordinates, osm_node_ids);
|
||||||
|
files::writeNodeData(config.edge_based_nodes_data_path, edge_based_nodes_container);
|
||||||
|
|
||||||
WriteEdgeBasedGraph(config.edge_graph_output_path, max_edge_id, edge_based_edge_list);
|
WriteEdgeBasedGraph(config.edge_graph_output_path, max_edge_id, edge_based_edge_list);
|
||||||
|
|
||||||
@ -335,7 +338,7 @@ void Extractor::WriteProfileProperties(const std::string &output_path,
|
|||||||
|
|
||||||
void Extractor::FindComponents(unsigned max_edge_id,
|
void Extractor::FindComponents(unsigned max_edge_id,
|
||||||
const util::DeallocatingVector<EdgeBasedEdge> &input_edge_list,
|
const util::DeallocatingVector<EdgeBasedEdge> &input_edge_list,
|
||||||
std::vector<EdgeBasedNode> &input_nodes) const
|
EdgeBasedNodeDataExternalContainer &input_nodes) const
|
||||||
{
|
{
|
||||||
using InputEdge = util::static_graph_details::SortableEdgeWithData<void>;
|
using InputEdge = util::static_graph_details::SortableEdgeWithData<void>;
|
||||||
using UncontractedGraph = util::StaticGraph<void>;
|
using UncontractedGraph = util::StaticGraph<void>;
|
||||||
@ -359,18 +362,6 @@ void Extractor::FindComponents(unsigned max_edge_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect forward and backward nodes of each edge
|
|
||||||
for (const auto &node : input_nodes)
|
|
||||||
{
|
|
||||||
if (node.reverse_segment_id.enabled)
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(node.forward_segment_id.id <= max_edge_id);
|
|
||||||
BOOST_ASSERT(node.reverse_segment_id.id <= max_edge_id);
|
|
||||||
edges.push_back({node.forward_segment_id.id, node.reverse_segment_id.id});
|
|
||||||
edges.push_back({node.reverse_segment_id.id, node.forward_segment_id.id});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tbb::parallel_sort(edges.begin(), edges.end());
|
tbb::parallel_sort(edges.begin(), edges.end());
|
||||||
edges.erase(std::unique(edges.begin(), edges.end()), edges.end());
|
edges.erase(std::unique(edges.begin(), edges.end()), edges.end());
|
||||||
|
|
||||||
@ -379,16 +370,14 @@ void Extractor::FindComponents(unsigned max_edge_id,
|
|||||||
TarjanSCC<UncontractedGraph> component_search(uncontracted_graph);
|
TarjanSCC<UncontractedGraph> component_search(uncontracted_graph);
|
||||||
component_search.Run();
|
component_search.Run();
|
||||||
|
|
||||||
for (auto &node : input_nodes)
|
stxxl::vector<ComponentID> component_ids;
|
||||||
|
component_ids.reserve(max_edge_id + 1);
|
||||||
|
for (NodeID node_id = 0; node_id <= max_edge_id; ++node_id)
|
||||||
{
|
{
|
||||||
auto forward_component = component_search.GetComponentID(node.forward_segment_id.id);
|
const auto forward_component = component_search.GetComponentID(node_id);
|
||||||
BOOST_ASSERT(!node.reverse_segment_id.enabled ||
|
const auto component_size = component_search.GetComponentSize(forward_component);
|
||||||
forward_component ==
|
const auto is_tiny = component_size < config.small_component_size;
|
||||||
component_search.GetComponentID(node.reverse_segment_id.id));
|
input_nodes.SetData(node_id, {1 + forward_component, is_tiny});
|
||||||
|
|
||||||
const unsigned component_size = component_search.GetComponentSize(forward_component);
|
|
||||||
node.component.is_tiny = component_size < config.small_component_size;
|
|
||||||
node.component.id = 1 + forward_component;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +421,8 @@ std::pair<std::size_t, EdgeID>
|
|||||||
Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
||||||
std::vector<util::Coordinate> &coordinates,
|
std::vector<util::Coordinate> &coordinates,
|
||||||
extractor::PackedOSMIDs &osm_node_ids,
|
extractor::PackedOSMIDs &osm_node_ids,
|
||||||
std::vector<EdgeBasedNode> &node_based_edge_list,
|
EdgeBasedNodeDataExternalContainer &ebg_node_data_container,
|
||||||
|
std::vector<EdgeBasedNode> &node_based_edges_list,
|
||||||
std::vector<bool> &node_is_startpoint,
|
std::vector<bool> &node_is_startpoint,
|
||||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||||
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
||||||
@ -477,7 +467,6 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
|||||||
turn_lane_map);
|
turn_lane_map);
|
||||||
|
|
||||||
edge_based_graph_factory.Run(scripting_environment,
|
edge_based_graph_factory.Run(scripting_environment,
|
||||||
config.edge_based_nodes_data_path,
|
|
||||||
config.edge_output_path,
|
config.edge_output_path,
|
||||||
config.turn_lane_data_file_name,
|
config.turn_lane_data_file_name,
|
||||||
config.turn_weight_penalties_path,
|
config.turn_weight_penalties_path,
|
||||||
@ -512,7 +501,8 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
|||||||
*compressed_edge_container.ToSegmentData());
|
*compressed_edge_container.ToSegmentData());
|
||||||
|
|
||||||
edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list);
|
edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list);
|
||||||
edge_based_graph_factory.GetEdgeBasedNodes(node_based_edge_list);
|
edge_based_graph_factory.GetEdgeBasedNodes(ebg_node_data_container);
|
||||||
|
edge_based_graph_factory.GetNodeBasedEdges(node_based_edges_list);
|
||||||
edge_based_graph_factory.GetStartPointMarkers(node_is_startpoint);
|
edge_based_graph_factory.GetStartPointMarkers(node_is_startpoint);
|
||||||
edge_based_graph_factory.GetEdgeBasedNodeWeights(edge_based_node_weights);
|
edge_based_graph_factory.GetEdgeBasedNodeWeights(edge_based_node_weights);
|
||||||
auto max_edge_id = edge_based_graph_factory.GetHighestEdgeID();
|
auto max_edge_id = edge_based_graph_factory.GetHighestEdgeID();
|
||||||
@ -532,21 +522,21 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
|||||||
|
|
||||||
Saves tree into '.ramIndex' and leaves into '.fileIndex'.
|
Saves tree into '.ramIndex' and leaves into '.fileIndex'.
|
||||||
*/
|
*/
|
||||||
void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edges_list,
|
||||||
std::vector<bool> node_is_startpoint,
|
std::vector<bool> node_is_startpoint,
|
||||||
const std::vector<util::Coordinate> &coordinates)
|
const std::vector<util::Coordinate> &coordinates)
|
||||||
{
|
{
|
||||||
util::Log() << "constructing r-tree of " << node_based_edge_list.size()
|
util::Log() << "constructing r-tree of " << node_based_edges_list.size()
|
||||||
<< " edge elements build on-top of " << coordinates.size() << " coordinates";
|
<< " edge elements build on-top of " << coordinates.size() << " coordinates";
|
||||||
|
|
||||||
BOOST_ASSERT(node_is_startpoint.size() == node_based_edge_list.size());
|
BOOST_ASSERT(node_is_startpoint.size() == node_based_edges_list.size());
|
||||||
|
|
||||||
// Filter node based edges based on startpoint
|
// Filter node based edges based on startpoint
|
||||||
auto out_iter = node_based_edge_list.begin();
|
auto out_iter = node_based_edges_list.begin();
|
||||||
auto in_iter = node_based_edge_list.begin();
|
auto in_iter = node_based_edges_list.begin();
|
||||||
for (auto index : util::irange<std::size_t>(0UL, node_is_startpoint.size()))
|
for (auto index : util::irange<std::size_t>(0UL, node_is_startpoint.size()))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(in_iter != node_based_edge_list.end());
|
BOOST_ASSERT(in_iter != node_based_edges_list.end());
|
||||||
if (node_is_startpoint[index])
|
if (node_is_startpoint[index])
|
||||||
{
|
{
|
||||||
*out_iter = *in_iter;
|
*out_iter = *in_iter;
|
||||||
@ -554,17 +544,17 @@ void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
|||||||
}
|
}
|
||||||
in_iter++;
|
in_iter++;
|
||||||
}
|
}
|
||||||
auto new_size = out_iter - node_based_edge_list.begin();
|
auto new_size = out_iter - node_based_edges_list.begin();
|
||||||
if (new_size == 0)
|
if (new_size == 0)
|
||||||
{
|
{
|
||||||
throw util::exception("There are no snappable edges left after processing. Are you "
|
throw util::exception("There are no snappable edges left after processing. Are you "
|
||||||
"setting travel modes correctly in the profile? Cannot continue." +
|
"setting travel modes correctly in the profile? Cannot continue." +
|
||||||
SOURCE_REF);
|
SOURCE_REF);
|
||||||
}
|
}
|
||||||
node_based_edge_list.resize(new_size);
|
node_based_edges_list.resize(new_size);
|
||||||
|
|
||||||
TIMER_START(construction);
|
TIMER_START(construction);
|
||||||
util::StaticRTree<EdgeBasedNode> rtree(node_based_edge_list,
|
util::StaticRTree<EdgeBasedNode> rtree(node_based_edges_list,
|
||||||
config.rtree_nodes_output_path,
|
config.rtree_nodes_output_path,
|
||||||
config.rtree_leafs_output_path,
|
config.rtree_leafs_output_path,
|
||||||
coordinates);
|
coordinates);
|
||||||
|
@ -250,7 +250,8 @@ void Storage::PopulateLayout(DataLayout &layout)
|
|||||||
const auto nodes_number = nodes_data_file.ReadElementCount64();
|
const auto nodes_number = nodes_data_file.ReadElementCount64();
|
||||||
|
|
||||||
layout.SetBlockSize<NodeID>(DataLayout::GEOMETRY_ID_LIST, nodes_number);
|
layout.SetBlockSize<NodeID>(DataLayout::GEOMETRY_ID_LIST, nodes_number);
|
||||||
layout.SetBlockSize<unsigned>(DataLayout::NAME_ID_LIST, nodes_number);
|
layout.SetBlockSize<NameID>(DataLayout::NAME_ID_LIST, nodes_number);
|
||||||
|
layout.SetBlockSize<ComponentID>(DataLayout::COMPONENT_ID_LIST, nodes_number);
|
||||||
layout.SetBlockSize<extractor::TravelMode>(DataLayout::TRAVEL_MODE_LIST, nodes_number);
|
layout.SetBlockSize<extractor::TravelMode>(DataLayout::TRAVEL_MODE_LIST, nodes_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,13 +595,20 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
|||||||
util::vector_view<NameID> name_ids(name_id_list_ptr,
|
util::vector_view<NameID> name_ids(name_id_list_ptr,
|
||||||
layout.num_entries[storage::DataLayout::NAME_ID_LIST]);
|
layout.num_entries[storage::DataLayout::NAME_ID_LIST]);
|
||||||
|
|
||||||
|
auto component_ids_ptr = layout.GetBlockPtr<ComponentID, true>(
|
||||||
|
memory_ptr, storage::DataLayout::COMPONENT_ID_LIST);
|
||||||
|
util::vector_view<ComponentID> component_ids(
|
||||||
|
component_ids_ptr, layout.num_entries[storage::DataLayout::COMPONENT_ID_LIST]);
|
||||||
|
|
||||||
auto travel_mode_list_ptr = layout.GetBlockPtr<extractor::TravelMode, true>(
|
auto travel_mode_list_ptr = layout.GetBlockPtr<extractor::TravelMode, true>(
|
||||||
memory_ptr, storage::DataLayout::TRAVEL_MODE_LIST);
|
memory_ptr, storage::DataLayout::TRAVEL_MODE_LIST);
|
||||||
util::vector_view<extractor::TravelMode> travel_modes(
|
util::vector_view<extractor::TravelMode> travel_modes(
|
||||||
travel_mode_list_ptr, layout.num_entries[storage::DataLayout::TRAVEL_MODE_LIST]);
|
travel_mode_list_ptr, layout.num_entries[storage::DataLayout::TRAVEL_MODE_LIST]);
|
||||||
|
|
||||||
extractor::EdgeBasedNodeDataView node_data(
|
extractor::EdgeBasedNodeDataView node_data(std::move(geometry_ids),
|
||||||
std::move(geometry_ids), std::move(name_ids), std::move(travel_modes));
|
std::move(name_ids),
|
||||||
|
std::move(component_ids),
|
||||||
|
std::move(travel_modes));
|
||||||
|
|
||||||
extractor::files::readNodeData(config.edge_based_nodes_data_path, node_data);
|
extractor::files::readNodeData(config.edge_based_nodes_data_path, node_data);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
|||||||
{
|
{
|
||||||
return GeometryID{SPECIAL_GEOMETRYID, false};
|
return GeometryID{SPECIAL_GEOMETRYID, false};
|
||||||
}
|
}
|
||||||
|
ComponentID GetComponentID(const NodeID /* id */) const override
|
||||||
|
{
|
||||||
|
return ComponentID{INVALID_COMPONENTID, false};
|
||||||
|
}
|
||||||
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned /* id */) const override final
|
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned /* id */) const override final
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -137,7 +137,6 @@ template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomGraphFixture
|
|||||||
if (used_edges.find(std::pair<unsigned, unsigned>(
|
if (used_edges.find(std::pair<unsigned, unsigned>(
|
||||||
std::min(data.u, data.v), std::max(data.u, data.v))) == used_edges.end())
|
std::min(data.u, data.v), std::max(data.u, data.v))) == used_edges.end())
|
||||||
{
|
{
|
||||||
data.component.id = 0;
|
|
||||||
edges.emplace_back(data);
|
edges.emplace_back(data);
|
||||||
used_edges.emplace(std::min(data.u, data.v), std::max(data.u, data.v));
|
used_edges.emplace(std::min(data.u, data.v), std::max(data.u, data.v));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user