Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/overpass_api/data/collect_members.cc
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,26 @@ Timeless< Uint32_Index, Node_Skeleton > paired_items_range(
}


Timeless< Uint32_Index, Node_Skeleton > relation_and_way_node_members(
Request_Context& context,
const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& relations,
const std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >& attic_relations,
const std::map< Uint31_Index, std::vector< Way_Skeleton > >& ways,
const std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >& attic_ways)
{
// Both id lists are sorted and free of duplicates.
std::vector< Node::Id_Type > rel_ids = relation_node_member_ids(relations, attic_relations);
std::vector< Node::Id_Type > way_ids = way_nd_ids(ways, attic_ways, 0);
context.get_health_guard().check();
std::vector< Node::Id_Type > ids;
ids.reserve(rel_ids.size() + way_ids.size());
std::set_union(rel_ids.begin(), rel_ids.end(), way_ids.begin(), way_ids.end(), std::back_inserter(ids));

return paired_items_range(context, ids,
relation_node_member_indices(relations, attic_relations).union_(way_nd_indices(ways, attic_ways)));
}


Timeless< Uint32_Index, Node_Skeleton > relation_node_members
(Request_Context& context,
const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& relations,
Expand Down Expand Up @@ -1065,6 +1085,23 @@ void add_nw_member_objects(Request_Context& context, const Set& input_set, Set&
{
Ranges< Uint32_Index > ranges_32(ranges_32_ ? *ranges_32_ : Ranges< Uint32_Index >::global());
Ranges< Uint31_Index > ranges_31(ranges_31_ ? *ranges_31_ : Ranges< Uint31_Index >::global());

if (context.get_desired_timestamp() == NOW && !ranges_32_)
{
// Collect the relations' node members and the ways' nodes in one pass over the node blocks.
relation_way_members(context, input_set.relations, {}, ranges_31, {}, true)
.swap(into.ways, into.attic_ways);
std::map< Uint31_Index, std::vector< Way_Skeleton > > source_ways = input_set.ways;
sort_second(source_ways);
sort_second(into.ways);
indexed_set_union(source_ways, into.ways);
Timeless< Uint32_Index, Node_Skeleton > nodes = relation_and_way_node_members(
context, input_set.relations, input_set.attic_relations, source_ways, {});
nodes.current.swap(into.nodes);
sort_second(into.nodes);
return;
}

Timeless< Uint32_Index, Node_Skeleton > rel_nodes
= relation_node_members(context, input_set.relations, input_set.attic_relations, ranges_32, {}, true);

Expand Down
12 changes: 12 additions & 0 deletions src/overpass_api/data/collect_members.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,18 @@ Ranges< Uint31_Index > relation_way_member_indices
Ranges< Uint32_Index > calc_node_children_ranges(const std::vector< uint32 >& way_rel_idxs);


/* The node members of the relations and the nodes of the ways, read in a single pass
over the node blocks. Equivalent to the union of relation_node_members(relations) and
way_members(ways) with global ranges, but blocks holding both kinds of node are read
and decompressed once instead of twice. */
Timeless< Uint32_Index, Node_Skeleton > relation_and_way_node_members(
Request_Context& context,
const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& relations,
const std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >& attic_relations,
const std::map< Uint31_Index, std::vector< Way_Skeleton > >& ways,
const std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >& attic_ways);


Ranges< Uint32_Index > relation_node_member_indices(
const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& current_rels,
const std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >& attic_rels);
Expand Down
11 changes: 3 additions & 8 deletions src/overpass_api/statements/recurse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1404,15 +1404,10 @@ void Recurse_Statement::execute(Resource_Manager& rman)
source_ways.set_union(result_ways.swap(into.ways, into.attic_ways).sort());
result_ways.swap(into.ways, into.attic_ways);
}
Timeless< Uint32_Index, Node_Skeleton > rel_nodes = relation_node_members(
context, into.relations, into.attic_relations, Ranges< Uint32_Index >::global(), {}, true);
// The relations' node members and the ways' nodes, in one pass over the node blocks.
Timeless< Uint32_Index, Node_Skeleton > rel_nodes = relation_and_way_node_members(
context, into.relations, into.attic_relations, source_ways.current, source_ways.attic);
rel_nodes.sort();
{
Timeless< Uint32_Index, Node_Skeleton > more_nodes
= way_members(context, source_ways.current, source_ways.attic, 0,
Ranges< Uint32_Index >::global(), {}, true);
rel_nodes.set_union(more_nodes.sort());
}
keep_matching_skeletons(rel_nodes.current, rel_nodes.attic, rman.get_desired_timestamp());
rel_nodes.swap(into.nodes, into.attic_nodes);
}
Expand Down