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

New filters based on counting functions #197

Closed
6 of 7 tasks
mmd-osm opened this issue Feb 13, 2015 · 6 comments
Closed
6 of 7 tasks

New filters based on counting functions #197

mmd-osm opened this issue Feb 13, 2015 · 6 comments

Comments

@mmd-osm
Copy link
Contributor

mmd-osm commented Feb 13, 2015

This issue collects a few enhancement requests for statistics-based filters from various forum posts, e.g. [1].

  • For nodes/ways/relations/areas: filter on the number of tags
  • For ways: filter on the number of (possibly distinct) nodes
  • For nodes: filter on the number of parent ways/relations
  • For relations: filter on the number of members
  • For relations: filter members with a specific role
  • For retations: filter members with a specific object type
  • For relations: filter on the total number of relation,way and node (and sum of those three object types) members.

For each "number", an exact value as well as a range (min.. max value) would be desirable.

Examples (not an actual syntax proposal):

rel(membercount:0);        // relations without members (note: no lat/lon available, global search needed)
way[highway](tagcount:1);  // way with single tag "highway"
node(parentwaycount:2..);  // nodes which occur in at least 2 ways 
way(nodecount:1);          // ways with a single node

Update April 12th 2015:

@GeorgV suggested the following generalizations to keep the number of keywords low:

(1) Change parentwaycount to parentcount - this would also allow to check in how many relations a way occurs. On the other hand, node(parentcount:2) might refer to a way or maybe even a relation, depending on the definition of a parent. I think this needs to be discussed in more detail.

(2) Change nodecount to membercount - interpreting nodes of a way as members seems reasonable, unless we want to differentiate between rel(nodecount) and way(nodecount).

Also, Georg mentioned that we need to specify, if respective counts refer to distinct numbers or not. In the case of a closed way, we would e.g. determine a nodecount of 4, but a distinctnodecount of 3.

@ all: if you have more ideas, please add them below. I will try to consolidate them later on.

This issue supersedes #180.

@ImreSamu
Copy link

interesting problems :

and filtering + exporting the number to csv

@sanderd17
Copy link

This would be a great feature.

CSV output is no problem now, that's related to the "out" settings, and already allows printing counts.

First implementation

For the syntax, why not follow JOSM syntax for this? The JOSM search tool has been offering this for a while, so should give some reference on what searches to include or exclude.

To answer some questions:
The syntax is

  • nodes:min-max: selects ways and relations that have from min to max nodes
  • ways:min-max: selects nodes and relations that have from min to max ways as member, or belong to that many ways
  • tags:min-max: selects nodes, ways and relations that have from min to max tags

There seems to be one thing missing from JOSM, which is counting relations. As relations can be counted in the parent or the child direction (something that doesn't happen with nodes and ways), this needs 2 queries

  • parentrelations:min-max: selects nodes, ways and relations that have between min and max parent relations
  • childrelations:min-max: selects nodes, ways and relations that have between min and max child relations

JOSM seems to ignore closing waypoints (so if the last waypoint is the same as the first, it doesn't get counted), but JOSM does not ignore other waypoints that overlap (f.e. when the way has self-intersections).

To filter out closed ways, JOSM has the special closed query. So in Overpass, this would be way(closed); as a query.

Future expansions

The above would be great for a first implementation of counting, but we should also leave room in the syntax for expansion:

  • Only count from a set
    For some reasons, it would be handy to count the number of elements further selected on other criteria. F.e. the nodes that belong to more than one highway way.
way["highway"]->.highways;
node(ways.highways:2-);
  • Count roles
    Or count only certain roles, this could be achieved by adding a filter after a comma. Like searching the relations that have more than 50 outer ways:
relation(ways:50-,role:"outer")

@matkoniecz
Copy link

interesting problems :

Or catching tagging mistake of area=yes, name=Playground instead of leisure=playground type - currently I see no way to search for "objects with area=yes and name tag and nothing else".

@drolbr
Copy link
Owner

drolbr commented May 4, 2017

For ways: filter on the number of (possibly distinct) nodes, and for relations: filter on the number of members:

  • see count_members() for number of members in general
  • distinct still to do

For relations: filter on the total number of relation,way and node (and sum of those three object types) members: this can be done with the counting functions as well. Use something like
way(if:count_members()>1000);

@drolbr
Copy link
Owner

drolbr commented May 13, 2017

The parent count will not be implemented as a direct function. Use a foreach loop with upward recurse instead.

Everything else is implemented.

@drolbr drolbr closed this as completed May 13, 2017
@mmd-osm
Copy link
Contributor Author

mmd-osm commented Sep 2, 2017

Closed ways are in #419

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants