Modify

Opened 15 years ago

Closed 11 years ago

Last modified 11 years ago

#4644 closed enhancement (fixed)

copy primitive id to clipboard

Reported by: vsandre Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: clipboard id Cc:

Description (last modified by skyper)

Please introduce a possibility to copy the primitive id to the clipboard.

style:
relation/12345 or way/123456 or node/1234567

How?
right click in the selection sidebar and "copy id"

Attachments (1)

4644_v1.patch (1.1 KB ) - added by xeen 11 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 by anonymous, 15 years ago

Do you know about ctrl-c ?

However it does not add the type of the object, only the id.

comment:2 by vsandre, 15 years ago

Nice, since which version?

So please add a preference entry to switch between the mentioned way and the existing methode.

comment:3 by simon04, 13 years ago

In r4347, when copying elements of different types (e.g., a node and a way), the clipboard contains a comma separated list of ids, but missing the type of the elements. As this is quite useless, one should think of generally adapting this behaviour.

by xeen, 11 years ago

Attachment: 4644_v1.patch added

comment:4 by xeen, 11 years ago

Copying relations works even without this patch and yields something like this (select relation in sidebar dialog, press ctrl+c):

{Relation id=1639515 version=1 VT [way 119206655, way 119206654]}

The attached patch generates the clip board content similar to:

node 1089302677,node 1089303458,way 93793372

It would also be possible to use the line commented out in the patch, which yields "closedway" instead of just "way" when a way is closed. Theoretically it could also emit multipolygon, but selection since each way is selected individually, this is not the case.

I’m unsure which to choose, although I’m leaning against the "closedway" option. Relation copy output works that way and closedway is only used internally in JOSM and is not present in OSM. If there are no objections, I will merge the patch (without the commented out line) once I remember to do so.

comment:5 by skyper, 11 years ago

Description: modified (diff)
Summary: copy primitive id to clipboard[patch] copy primitive id to clipboard

comment:6 by xeen, 11 years ago

Resolution: fixed
Status: newclosed

In 6320/josm:

include primitive type when copying IDs to clipboard (fixes #4644)

comment:7 by verdy_p, 11 years ago

Instead of using "node <id>", "way <id>", "relation <id>", this should use the same syntax used in the object loader :
"n<id>", "w<id>", "r<id>".
This woud allow the same parser and would also save memory with faster copy operations, and easier pasting from one instance of JOSM to another when opening the object loader dialog (no manual editing needed after pasting the string into the dialog).

comment:8 by verdy_p, 11 years ago

Patch at lines 52-53:

    idsBuilder.append(OsmPrimitiveType.from(p).charAt(0)).append(p.getId()).append(",")

There should be an API like this in class Primitive:

    String Primitive.getFullId() {
       StringBuilder sb = new StringBuilder();
       return sb.append(OsmPrimitiveType.from(this).charAt(0).append(getId()).toString();
    }

So the lines 52-53 should become simply:

    idsBuilder.append(p.getFullId().append(','));

Note: it's more efficient to append a char rather than a String in a StringBuilder, this avoids extra references to the String object (getting the source string length, checking internal buffer size in the String Builder, and performing char arraycopies with additional references to the source array).

comment:9 by skyper, 11 years ago

Resolution: fixed
Status: closedreopened
Summary: [patch] copy primitive id to clipboardcopy primitive id to clipboard

r6320 broke some parts of copy and paste all properties.

  1. select two nodes with same properties.
  2. Ctrl+C
  3. Select some other nodes
  4. Ctrl+Shift+V

I get a warning.

#9200 is similar also I got this kind of string only once and do not remember what I did.

comment:10 by skyper, 11 years ago

Do not know if verdy_p's comment was respected but my part was fixed with r6321.

comment:11 by verdy_p, 11 years ago

No, the code still copies the English primitive name (way, node, relation) followed by a space and the numeric id.
This syntax does not work in the dialog for downloading objects which uses only the first letter (w, n, r) witout separator before the numeric id.

comment:12 by simon04, 11 years ago

Resolution: fixed
Status: reopenedclosed

I don't see a big gain from comment:8 since it doesn't adapt potential other places in the source code and getFullId seems to be an unclear method name to me.

We're happy to take patches though which improve the code in a larger scope (then please open a separate ticket) :-)

comment:13 by anonymous, 11 years ago

Why a new ticket ? the clipboard is effectively used to copy-paste into the download dialog, which has a separate syntax (and does not support the syntax "node/<id>" but only "n<id>".

The term "FullId" is significant because the Id alone is not enough to reference an object without the type.

Whatver you do, the short syntax "n<id>" MUST be qualifying and there was NO gain in inventing another syntax for the clipboard, which does not work with the user interface. So all primitive types have to define a one-letter synonym used in the short form: "r" alone is better than "relation/", as this saves memory for large selections in the clipboard.

The clipboard parser can easily use a regexp like "(n(ode\/)?|w(ay\/)?|r(elation\/)?([0-9]+)" to parse the id's in the clipboard with both formats. And in fact the short format should still be preferred in the clipboard to support selection of long lists of objects.

comment:14 by simon04, 11 years ago

Because it's hard to grasp the open fragments from tickets with 20 comments.

I'm not opposed to your suggestion, but when having a OsmPrimitive.getFullId method, I'd like to see it used everywhere in the code and not just at one spot. Maybe getIdWithType is a clearer name? When shortening relation to r, we need to adapt the regexp from r6321.

Btw: r6674 is somewhat related.

Last edited 11 years ago by simon04 (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.