Ticket #10225: 10225.patch

File 10225.patch, 1.6 KB (added by GerdP, 7 years ago)

Possible solution

  • src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java

     
    211211        boolean overrideNewCheck = false;
    212212        int idxNew = selection.get(0).isNew() ? 0 : 1;
    213213        if (selection.get(1-idxNew).isNew()) {
    214             // if both are new, select the one with all the DB nodes
    215             boolean areNewNodes = false;
    216             for (Node n : selection.get(0).getNodes()) {
    217                 if (n.isNew()) {
    218                     areNewNodes = true;
    219                 }
    220             }
    221             idxNew = areNewNodes ? 0 : 1;
    222             overrideNewCheck = true;
    223             for (Node n : selection.get(1 - idxNew).getNodes()) {
    224                 if (n.isNew()) {
    225                     overrideNewCheck = false;
    226                 }
    227             }
     214            // if both are new, select the one with DB nodes if the other has none
     215                boolean hasOldS0 = selection.get(0).getNodes().stream().anyMatch(n->!n.isNew());
     216                boolean hasOldS1 = selection.get(1).getNodes().stream().anyMatch(n->!n.isNew());
     217                if (hasOldS0 != hasOldS1) {
     218                        overrideNewCheck = true;
     219                        if (hasOldS0) {
     220                                idxNew = 1;
     221                        }
     222                }
    228223        }
    229224        Way referenceWay = selection.get(idxNew);
    230225        Way subjectWay = selection.get(1 - idxNew);