#16808 closed defect (wontfix)
Merging two nodes does not preserve the longest history
| Reported by: | pangoSE | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Core | Version: | |
| Keywords: | merge history | Cc: |
Description
Hi
Merging two nodes does not always preserve the longest history.
Is it possible to implement this?
Cheers
Attachments (0)
Change History (5)
comment:1 by , 7 years ago
| Keywords: | merge history added |
|---|
comment:2 by , 7 years ago
comment:3 by , 7 years ago
Yes:
/** * Find which node to merge into (i.e. which one will be left) * * @param candidates the collection of candidate nodes * @return the selected target node */ public static Node selectTargetNode(Collection<Node> candidates) { Node oldestNode = null; Node targetNode = null; Node lastNode = null; for (Node n : candidates) { if (!n.isNew()) { // Among existing nodes, try to keep the oldest used one if (!n.getReferrers().isEmpty()) { if (targetNode == null || n.getId() < targetNode.getId()) { targetNode = n; } } else if (oldestNode == null || n.getId() < oldestNode.getId()) { oldestNode = n; } } lastNode = n; } return Optional.ofNullable(targetNode).orElse(oldestNode != null ? oldestNode : lastNode); }
comment:4 by , 7 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
comment:5 by , 7 years ago
Perfect.
When I edit and merge nodes I would like JOSM to specify in the changeset in some way that the deleted nodes stem from merging nodes.
Is that possible?
It seems that changesets can have tags when looking at https://www.openstreetmap.org/changeset/63276307
Maybe the changeset tags:
deleted_nodes_from_merging = yes
deleted_nodes_from_merging:procent = 100
or something like that would be suitable.
That way I and tools can easier destinguish edits with a lot of deleted nodes that is not a result of merges.



As far as I remember it preserves the history of the oldest node (i.e. lower id).