Modify

Opened 4 years ago

Closed 4 years ago

#2602 closed enhancement (fixed)

[PATCH] Search keywords "child" and "parent"

Reported by: Matt Owned by: team
Priority: minor Component: Core
Version: Keywords: search
Cc:

Description

It has been noted that search keywords for parent/child relationships would be useful, http://www.mail-archive.com/josm-dev@openstreetmap.org/msg01869.html

Attachments (3)

josm.child-parent-search.patch (3.7 KB) - added by Matt 4 years ago.
Patch to add "child" and "parent" keywords to search.
josm.child-parent-search.2.patch (4.1 KB) - added by Matt 4 years ago.
A better patch for parent/child relationship search.
josm.child-parent-search.3.patch (4.5 KB) - added by avar 4 years ago.
attachment:josm.child-parent-search.3.patch with minor fixes

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by Matt

Patch to add "child" and "parent" keywords to search.

comment:1 follow-up: Changed 4 years ago by smsm1

  • Summary changed from Search keywords "child" and "parent" to [PATCH] Search keywords "child" and "parent"

comment:2 in reply to: ↑ 1 Changed 4 years ago by avar

Nice patch, but the child and parent operators can't be used in conjunction with any other search terms. I.e. "type:way" and then "child" works for finding all nodes which belong to ways, but "type:way child" doesn't. Neither does combining them with anything else.

And "parent child" doesn't work, which I would expect to find all relations a way belongs to and all of its nodes when I have a way selected that's a member of a relation.

comment:3 follow-up: Changed 4 years ago by Matt

Here's a better patch, which allows expression "arguments" to the parent and child keywords. For example, to select all neighbouring ways of a selected way, "parent(child(selected)) type:way" works nicely. The parentheses are optional for single-argument expressions, but its more readable to keep them. (i.e: the above could have been "parent child selected type:way")

Changed 4 years ago by Matt

A better patch for parent/child relationship search.

comment:4 in reply to: ↑ 3 Changed 4 years ago by avar

Replying to Matt:

Here's a better patch, which allows expression "arguments" to the parent and child keywords. For example, to select all neighbouring ways of a selected way, "parent(child(selected)) type:way" works nicely. The parentheses are optional for single-argument expressions, but its more readable to keep them. (i.e: the above could have been "parent child selected type:way")

This minor patch improves upon your patch:

  • "child" or "parent" i.e. without argument is no longer a NullPointerException but equivalent to "parent()" or "child()" respectively. I.e. it'll match everything that's the child or parent of some other object. I thought about making it an error about "child/parent without argument" but that would be inconsistent with the rest of the search syntax where omitting optional expressions always means "match everything".
  • The operators now stringify to child() and parent() instead of childof() and parentof()

Other than that I've tested this patch extensively and it's working just as expected. I can now do, for example:

parent(parent(type:node ^highway$:^traffic_signals$) ^highway$:^trunk$) ^type$:^route$

To select all route relations which cover trunk ways which have a traffic signal.

comment:5 Changed 4 years ago by stoecker

  • Resolution set to fixed
  • Status changed from new to closed

In r1603.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed .
as The resolution will be set. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.