Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement area size heuristic for area:id queries #364

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
23 changes: 16 additions & 7 deletions src/overpass_api/statements/area_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,35 @@ void Area_Query_Statement::get_ranges

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int counter = 0 in line 311 should probably be removed as well, otherwise line 321 won't return the correct value I guess (variable counter gets shadowed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right! forgot to remove that one


// Count the indicies of the input areas
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.handle().id().val())
counter += it.object().used_indices.size();
}
}
else
{
std::map< std::string, Set >::const_iterator mit = rman.sets().find(area->get_input());
if (mit == rman.sets().end())
return true;

// Count the indicies of the input areas
int counter = 0;

for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator it = mit->second.areas.begin();
it != mit->second.areas.end(); ++it)
{
for (std::vector< Area_Skeleton >::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
counter += it2->used_indices.size();
}

return (counter <= 12);
}

return (counter <= 12);
}


Expand Down
3 changes: 2 additions & 1 deletion src/overpass_api/statements/area_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ 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; }
std::string get_input() const { return input; }

static bool is_used() { return is_used_; }

virtual std::string dump_xml(const std::string& indent) const
Expand Down