Changeset 29559 in osm for applications


Ignore:
Timestamp:
2013-05-06T01:26:22+02:00 (12 years ago)
Author:
donvip
Message:

[josm_reverter] fix #josm8676 - Nodes unnecessary reverted because of recent handling of nodes without coordinates

Location:
applications/editors/josm/plugins/reverter/src/reverter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r29553 r29559  
    423423                OsmPrimitive p = ds.getPrimitiveById(id);
    424424                if (p instanceof Node && p.getVersion() > 1) {
    425                     final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader();
    426                     readObjectVersion(rdr, id, p.getVersion()-1, progressMonitor);
    427                     Collection<OsmPrimitive> result = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)).allPrimitives();
    428                     if (!result.isEmpty()) {
    429                         n.setCoor(((Node)result.iterator().next()).getCoor());
     425                    LatLon coor = ((Node)p).getCoor();
     426                    if (coor == null) {
     427                        final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader();
     428                        readObjectVersion(rdr, id, p.getVersion()-1, progressMonitor);
     429                        Collection<OsmPrimitive> result = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)).allPrimitives();
     430                        if (!result.isEmpty()) {
     431                            coor = ((Node)result.iterator().next()).getCoor();
     432                        }
    430433                    }
     434                    if (coor != null) {
     435                        n.setCoor(coor);
     436                    }
    431437                }
    432438            }
  • applications/editors/josm/plugins/reverter/src/reverter/DataSetCommandMerger.java

    r23273 r29559  
    4141        merge();
    4242    }
     43   
     44    private void addChangeCommandIfNotEquals(OsmPrimitive target, OsmPrimitive newTarget) {
     45        if (!target.hasEqualSemanticAttributes(newTarget)) {
     46            cmds.add(new ChangeCommand(target,newTarget));
     47        }
     48    }
    4349
    4450    private OsmPrimitive getMergeTarget(OsmPrimitive mergeSource) {
     
    6975        Node newTarget = new Node(target);
    7076        mergePrimitive(source, target, newTarget);
    71         cmds.add(new ChangeCommand(target,newTarget));
     77        addChangeCommandIfNotEquals(target,newTarget);
    7278    }
    7379
     
    9399                Node undeletedTargetNode = new Node(targetNode);
    94100                undeletedTargetNode.setDeleted(false);
    95                 cmds.add(new ChangeCommand(targetNode,undeletedTargetNode));
     101                addChangeCommandIfNotEquals(targetNode,undeletedTargetNode);
    96102            }
    97103            newNodes.add(targetNode);
     
    100106        mergePrimitive(source, target, newTarget);
    101107        newTarget.setNodes(newNodes);
    102         cmds.add(new ChangeCommand(target,newTarget));
     108        addChangeCommandIfNotEquals(target,newTarget);
    103109    }
    104110
     
    128134                }
    129135                undeletedTargetMember.setDeleted(false);
    130                 cmds.add(new ChangeCommand(targetMember,undeletedTargetMember));
     136                addChangeCommandIfNotEquals(targetMember,undeletedTargetMember);
    131137            }
    132138            newMembers.add(new RelationMember(sourceMember.getRole(), targetMember));
     
    135141        mergePrimitive(source, target, newRelation);
    136142        newRelation.setMembers(newMembers);
    137         cmds.add(new ChangeCommand(target,newRelation));
     143        addChangeCommandIfNotEquals(target,newRelation);
    138144    }
     145   
    139146    private void merge() {
    140147        for (Node node: sourceDataSet.getNodes()) {
Note: See TracChangeset for help on using the changeset viewer.