Skip to content

Commit 200debd

Browse files
committed
implement area size heuristic for area:id queries
fixes #359
1 parent 6e4d723 commit 200debd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/overpass_api/statements/area_query.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,20 @@ void Area_Query_Statement::get_ranges
287287

288288
bool Area_Constraint::delivers_data(Resource_Manager& rman)
289289
{
290+
int counter = 0;
291+
290292
if (!area->areas_from_input())
291-
return false;
293+
{
294+
Block_Backend< Uint31_Index, Area_Skeleton > area_locations_db
295+
(rman.get_area_transaction()->data_index(area_settings().AREAS));
296+
for (Block_Backend< Uint31_Index, Area_Skeleton >::Flat_Iterator
297+
it(area_locations_db.flat_begin());
298+
!(it == area_locations_db.flat_end()); ++it)
299+
{
300+
if (area->get_submitted_id() == it.object().id.val())
301+
counter += it.object().used_indices.size();
302+
}
303+
}
292304
else
293305
{
294306
map< string, Set >::const_iterator mit = rman.sets().find(area->get_input());
@@ -305,8 +317,8 @@ bool Area_Constraint::delivers_data(Resource_Manager& rman)
305317
counter += it2->used_indices.size();
306318
}
307319

308-
return (counter <= 12);
309320
}
321+
return (counter <= 12);
310322
}
311323

312324

src/overpass_api/statements/area_query.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Area_Query_Statement : public Output_Statement
7171
const Statement& query, Resource_Manager& rman);
7272

7373
bool areas_from_input() const { return (submitted_id == 0); }
74+
long long get_submitted_id() const { return submitted_id; }
7475
string get_input() const { return input; }
7576

7677
static bool is_used() { return is_used_; }

0 commit comments

Comments
 (0)