Skip to content

Commit

Permalink
implement area size heuristic for area:id queries
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrasd committed Mar 2, 2017
1 parent 6e4d723 commit 4fa2e8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/overpass_api/statements/area_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,21 @@ void Area_Query_Statement::get_ranges

bool Area_Constraint::delivers_data(Resource_Manager& rman)
{
int counter = 0;

if (!area->areas_from_input())
return false;
{

Block_Backend< Uint31_Index, Area_Skeleton > area_locations_db
(rman.get_area_transaction()->data_index(area_settings().AREAS));
for (Block_Backend< Uint31_Index, Area_Skeleton >::Flat_Iterator
it(area_locations_db.flat_begin());
!(it == area_locations_db.flat_end()); ++it)
{
if (area->get_submitted_id() == it.object().id.val())
counter += it.object().used_indices.size();
}
}
else
{
map< string, Set >::const_iterator mit = rman.sets().find(area->get_input());
Expand All @@ -305,8 +318,8 @@ bool Area_Constraint::delivers_data(Resource_Manager& rman)
counter += it2->used_indices.size();
}

return (counter <= 12);
}
return (counter <= 12);
}


Expand Down
1 change: 1 addition & 0 deletions src/overpass_api/statements/area_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Area_Query_Statement : public Output_Statement
const Statement& query, Resource_Manager& rman);

bool areas_from_input() const { return (submitted_id == 0); }
long long get_submitted_id() const { return submitted_id; }
string get_input() const { return input; }

static bool is_used() { return is_used_; }
Expand Down

0 comments on commit 4fa2e8e

Please sign in to comment.